>>> from diem import jsonrpc, testnet
>>> client = jsonrpc.Client(testnet.JSON_RPC_URL)
>>> client.get_metadata()
version: 3300304
timestamp: 1601492912847973
chain_id: 2You can find more examples under the examples directory:
Note: make test runs all examples too, see the Makefile for details.
Wallet Example: this is a highly simplified example of a wallet backend server implementation (no UI, no database, no un-related APIs) for demonstrating building off-chain API services through the Python SDK off-chain module.
To start the example as a local http server:
make init
source venv/bin/activate
make server
Example curl to hit the server (should get an error response):
curl -X POST -H "X-REQUEST-ID: 3185027f-0574-6f55-2668-3a38fdb5de98" -H "X-REQUEST-SENDER-ADDRESS: tdm1pacrzjajt6vuamzkswyd50e28pg77m6wylnc3spg3xj7r6" -d "invalid-jws-body" http://localhost:8080/v2/command
make init
make test
run specific test:
TEST=<test file / test name> make test
SPEC = specification
DIP-X = Diem Improvement Protocol
Root module name: diem
Sub-modules:
jsonrpc: diem JSON-RPC APIs client and API response types. SPECstdlib: generated code, move stdlib script utils for constructing transaction script playload.diem_types: generated code, Diem on-chain data structure types for encoding and decoding BCS data.utils: utility functions, account address utils, currency code, hashing, hex encoding / decoding, transaction utils.AuthKey|auth_key: auth key utilsidentifier: Diem Account Identifier and Diem Intent Identifier. DIP-5txnmetadata: utils for creating peer to peer transaction metadata. DIP-4testnet: Testnet utility, minting coins, create Testnet client, chain id, Testnet JSON-RPC URL.LocalAccount|local_account: utility for managing local account keys, generate random local account.chain_ids: list of static chain ids