Utility Chain API
info
The concept of networkID and chainID are both different when compared between Ethereum & Dijets.
Ethereum has its own notion of them whereas Dijets view of networkID and chainID are purely internal to Dijets
Utility Chain.
Mainnet, the Utility Chain uses 1 and 98200 for these values. On the Dijets TestNet Testnet, it uses 1 and
98199 for these values. networkID and chainID can also be obtained using the net_version and
eth_chainId methods.
Deploying a Smart Contract#
Deploy a Smart Contract on Dijets Using Remix and MetaMask
Ethereum APIs#
Endpoints#
JSON-RPC Endpoints
To interact with Utility Chain via the JSON-RPC endpoint:
/ext/bc/C/rpc
To interact with other instances of the EVM via the JSON-RPC endpoint:
/ext/bc/blockchainID/rpc
where `blockchainID` is the ID of the blockchain running the EVM.
#### WebSocket Endpoints
<Admonition type="info">
On the [public API node](../public-api-server.md#supported-apis), it only supports Utility Chain
websocket API calls for API methods that don't exist on the Utility Chain's HTTP API
</Admonition>
To interact with Utility Chain via the websocket endpoint:
```text
/ext/bc/C/ws
For example, to interact with the Utility Chain's Ethereum APIs via websocket on localhost you can use:
ws://127.0.0.1:9650/ext/bc/C/ws
info
On localhost, use ws://. When using the Public API or another host that
supports encryption, use wss://.
To interact with other instances of the EVM via the websocket endpoint:
/ext/bc/blockchainID/ws
where blockchainID is the ID of the blockchain running the EVM.
Standard Ethereum APIs#
Dijets offers an API interface identical to Geth's API except that it only supports the following services:
web3_net_eth_personal_txpool_debug_(note: this is turned off on the public API node.)
You can interact with these services the same exact way you’d interact with Geth. See the Ethereum Wiki’s JSON-RPC Documentation and Geth’s JSON-RPC Documentation for a full description of this API.
info
For batched requests on the public API node , the maximum number of items is 40. We are working on to support a larger batch size.
eth_getAssetBalance#
In addition to the standard Ethereum APIs, Dijets offers eth_getAssetBalance to retrieve the
balance of first class Dijets Native Tokens on the Utility Chain (excluding DJTX, which must be fetched
with eth_getBalance).
Signature:
eth_getAssetBalance({ address: string, blk: BlkNrOrHash, assetID: string, }) -> {balance: int}
addressowner of the assetblkis the block number or hash at which to retrieve the balanceassetIDid of the asset for which the balance is requested
Example Call:
curl -X POST --data '{ "jsonrpc": "2.0", "method": "eth_getAssetBalance", "params": [ "0x8723e5773847A4Eb5FeEDabD9320802c5c812F46", "latest", "3RvKBAmQnfYionFXMfW5P8TDZgZiogKbHjM8cjpu16LKAgF5T" ], "id": 1 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/rpc
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1388"
}
eth_baseFee#
Get the base fee for the next block.
Signature:
eth_baseFee() -> {}
result is the hex value of the base fee for the next block.
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"eth_baseFee", "params" :[] }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/rpc
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x34630b8a00"
}
eth_maxPriorityFeePerGas#
Get the priority fee needed to be included in a block.
Signature:
eth_maxPriorityFeePerGas() -> {}
result is hex value of the priority fee needed to be included in a block.
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"eth_maxPriorityFeePerGas", "params" :[] }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/rpc
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x2540be400"
}
For more information on dynamic fees see the Utility Chain section of the transaction fee documentation.
eth_getChainConfig#
eth_getChainConfig returns chain config. This API is enabled by default with internal-eth
namespace.
Signature:
eth_getChainConfig({}) -> {chainConfig: json}
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"eth_getChainConfig", "params" :[] }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/rpc
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"chainId": 98200,
"homesteadBlock": 0,
"daoForkBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"apricotPhase1BlockTimestamp": 0,
"apricotPhase2BlockTimestamp": 0,
"apricotPhase3BlockTimestamp": 0,
"apricotPhase4BlockTimestamp": 0,
"apricotPhase5BlockTimestamp": 0
}
}
Dijets Specific APIs#
To interact with the djtx specific RPC calls on the Utility Chain:
/ext/bc/C/djtx
To interact with other instances of the EVM DJTX endpoints:
/ext/bc/blockchainID/djtx
djtx.export#
caution
Not recommended for use on Mainnet. See warning notice in Keystore API.
Export an asset from the Utility Chain to Value Chain or Method Chain. After calling this method, you must call the
Value Chain's avm.import or Method Chain's
platform.import.
Signature:
djtx.export({ to: string, amount: int, assetID: string, baseFee: int, username: string, password:string, }) -> {txID: string}
tois the Value Chain or Method Chain address the asset is sent to.amountis the amount of the asset to send.assetIDis the ID of the asset. To export DJTX use"DJTX"as theassetID.baseFeeis the base fee that should be used when creating the transaction. If omitted, a suggested fee will be used.usernameis the user that controls the address that transaction will be sent from.passwordisusername‘s password.
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.export", "params" :{ "to":"X-dijets18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "amount": 500, "assetID": "2nzgmhZLuVq8jc7NNu2eahkKwoJcbFWXWJCxHBVWAJEZkhquoK", "username":"myUsername", "password":"myPassword" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"result": {
"txID": "2W5JuFENitZKTpJsy9igBpTcEeBKxBHHGAUkgsSUnkjVVGQ9i8"
},
"id": 1
}
djtx.exportDJTX#
caution
Not recommended for use on Mainnet. See warning notice in Keystore API.
Send DJTX from the Utility Chain to Value Chain or Method Chain. After calling this method, you must call the
Value Chain's avm.import or Method Chain's
platform.import with assetID DJTX on the Value Chain to complete
the transfer.
Signature:
djtx.exportDJTX({ to: string, amount: int, baseFee: int, username: string, password:string, }) -> {txID: string}
Request:
tois Value Chain or Method Chain address the asset is sent to.amountis the amount of the asset to send.baseFeeis the base fee that should be used when creating the transaction. If omitted, a suggested fee will be used.usernameis the user that controls the address that transaction will be sent from.passwordisusername‘s password.
Response:
txIDis the TXID of the completed ExportTx.
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.exportDJTX", "params" :{ "from": ["0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"], "to":"X-dijets18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "amount": 500, "changeAddr": "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC", "username":"myUsername", "password":"myPassword" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"result": {
"txID": "2ffcxdkiKXXA4JdyRoS38dd7zoThkapNPeZuGPmmLBbiuBBHDa"
},
"id": 1
}
djtx.exportKey#
caution
Not recommended for use on Mainnet. See warning notice in Keystore API.
Get the private key that controls a given address. The returned private key can be added to a user
with djtx.importKey.
Signature:
djtx.exportKey({ username: string, password:string, address:string }) -> {privateKey: string}
Request:
usernamemust controladdress.addressis the address for which you want to export the corresponding private key. It should be in hex format.
Response:
privateKeyis the CB58 encoded string representation of the private key that controlsaddress. It has aPrivateKey-prefix and can be used to import a key viadjtx.importKey.privateKeyHexis the hex string representation of the private key that controlsaddress. It can be used to import an account into MetaMask.
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.exportKey", "params" :{ "username" :"myUsername", "password":"myPassword", "address": "0xc876DF0F099b3eb32cBB78820d39F5813f73E18C" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"result": {
"privateKey": "PrivateKey-2o2uPgTSf3aR5nW6yLHjBEAiatAFKEhApvYzsjvAJKRXVWCYkE",
"privateKeyHex": "0xec381fb8d32168be4cf7f8d4ce9d8ca892d77ba574264f3665ad5edb89710157"
},
"id": 1
}
djtx.getAtomicTx#
Gets a transaction by its ID. Optional encoding parameter to specify the format for the returned
transaction. Can only be hex when a value is provided.
Signature:
djtx.getAtomicTx({ txID: string, encoding: string, //optional }) -> { tx: string, encoding: string, blockHeight: string }
Request:
txIDis the transaction ID. It should be in cb58 format.encodingis the encoding format to use. Can only behexwhen a value is provided.
Response:
txis the transaction encoded toencoding.encodingis theencoding.blockHeightis the height of the block which the transaction was included in.
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.getAtomicTx", "params" :{ "txID":"2GD5SRYJQr2kw5jE73trBFiAgVQyrCaeg223TaTyJFYXf2kPty", "encoding": "hex" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"result": {
"tx": "0x000000000000000030399d0775f450604bd2fbc49ce0c5c1c6dfeb2dc2acb8c92c26eeae6e6df4502b19d891ad56056d9c01f18f43f58b5c784ad07a4a49cf3d1f11623804b5cba2c6bf000000018212d6807a0ec9c1b26321418fe7a548180b5be728ce53fe7e98ab5755ed316100000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000005000003a352a382400000000100000000000000018db97c7cece249c2b98bdc0226cc4c2a57bf52fc000003a3529edd17dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000010000000900000001ead19377f015422fbb8731204fcf6d6879dd05146c2d5b5594e2fea2cb420b2f40bd457b71e279e547790b28fe5482f278c76cf39b2dce5c2e6c53352fe6827d002cc7d20d",
"encoding": "hex",
"blockHeight": "1"
},
"id": 1
}
djtx.getAtomicTxStatus#
Get the status of an atomic transaction sent to the network.
Signature:
djtx.getAtomicTxStatus({txID: string}) -> { status: string, blockHeight: string // returned when status is Accepted }
status is one of:
Accepted: The transaction is (or will be) accepted by every node. Check theblockHeightpropertyProcessing: The transaction is being voted on by this nodeDropped: The transaction was dropped by this node because it thought the transaction invalidUnknown: The transaction hasn’t been seen by this node
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.getAtomicTxStatus", "params" :{ "txID":"2QouvFWUbjuySRxeX5xMbNCuAaKWfbk5FeEa2JmoF85RKLk2dD" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"status": "Accepted",
"blockHeight": "1"
}
}
djtx.getUTXOs#
Gets the UTXOs that reference a given address.
Signature:
djtx.getUTXOs( { addresses: string, limit: int, //optional startIndex: { //optional address: string, utxo: string }, sourceChain: string, encoding: string, //optional }, ) -> { numFetched: int, utxos: []string, endIndex: { address: string, utxo: string } }
utxosis a list of UTXOs such that each UTXO references at least one address inaddresses.- At most
limitUTXOs are returned. Iflimitis omitted or greater than 1024, it is set to 1024. - This method supports pagination.
endIndexdenotes the last UTXO returned. To get the next set of UTXOs, use the value ofendIndexasstartIndexin the next call. - If
startIndexis omitted, will fetch all UTXOs up tolimit. - When using pagination (that is when
startIndexis provided), UTXOs are not guaranteed to be unique across multiple calls. That is, a UTXO may appear in the result of the first call, and then again in the second call. - When using pagination, consistency is not guaranteed across multiple calls. That is, the UTXO set of the addresses may have changed between calls.
encodingsets the format for the returned UTXOs. Can only behexwhen a value is provided.
Example
Suppose we want all UTXOs that reference at least one of
C-dijets18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5.
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.getUTXOs", "params" :{ "addresses":["C-dijets18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], "sourceChain": "X", "startIndex": { "address": "C-dijets18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "utxo": "22RXW7SWjBrrxu2vzDkd8uza7fuEmNpgbj58CxBob9UbP37HSB" }, "encoding": "hex" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
This gives response:
{
"jsonrpc": "2.0",
"result": {
"numFetched": "3",
"utxos": [
"0x0000a799e7448acf74ca9223159a04f93b948f99cf28509f908839532b2f85baffc300000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c22d23171",
"0x00006385c683d43bdbe754c224be36c5004ea7ce49c0849cadeaea6af93dae18cc7700000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29cb81cc877",
"0x000038137283c94582351b86c3e90808312636769e3f5c14fbf1152d6634f770695c00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c7412490e"
],
"endIndex": {
"address": "C-dijets18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "0x9333ef8a05f26acf2d8766f94723f749870fa2ca80c19c33cc945d79013d7c50fd023beb"
},
"encoding": "hex"
},
"id": 1
}
djtx.import#
caution
Not recommended for use on Mainnet. See warning notice in Keystore API.
Finalize the transfer of a non-DJTX or DJTX from Value Chain or Method Chain to the Utility Chain. Before this
method is called, you must call the Value Chain’s avm.export or Method Chain’s
platform.exportDJTX with assetID DJTX to initiate the transfer.
Signature:
djtx.import({ to: string, sourceChain: string, baseFee: int, // optional username: string, password:string, }) -> {txID: string}
Request:
tois the address the asset is sent to. This must be the same as thetoargument in the corresponding call to the Value Chain's or Method Chain'sexport.sourceChainis the ID or alias of the chain the asset is being imported from. To import funds from the Value Chain, use"X"; for the Method Chain, use"P".baseFeeis the base fee that should be used when creating the transaction. If omitted, a suggested fee will be used.usernameis the user that controls the address that transaction will be sent from.passwordisusername‘s password.
Response:
txIDis the ID of the completed ImportTx.
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.import", "params" :{ "to":"0x4b879aff6b3d24352Ac1985c1F45BA4c3493A398", "sourceChain":"X", "username":"myUsername", "password":"myPassword" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"result": {
"txID": "6bJq9dbqhiQvoshT3uSUbg9oB24n7Ei6MLnxvrdmao78oHR9t"
},
"id": 1
}
djtx.importDJTX#
caution
Not recommended for use on Mainnet. See warning notice in Keystore API.
Finalize a transfer of DJTX from the Value Chain or Method Chain to the Utility Chain. Before this method is
called, you must call the Value Chain’s avm.export or Method Chain’s
platform.exportDJTX with assetID DJTX to initiate the transfer.
Signature:
djtx.importDJTX({ to: string, sourceChain: string, baseFee: int, // optional username: string, password:string, }) -> {txID: string}
Request:
tois the address the DJTX is sent to. It should be in hex format.sourceChainis the ID or alias of the chain the DJTX is being imported from. To import funds from the Value Chain, use"X"; for the Method Chain, use"P".baseFeeis the base fee that should be used when creating the transaction. If omitted, a suggested fee will be used.usernameis the user that controls the address that transaction will be sent from.passwordisusername‘s password.
Response:
txIDis the ID of the completed ImportTx.
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.importDJTX", "params" :{ "to":"0x4b879aff6b3d24352Ac1985c1F45BA4c3493A398", "sourceChain":"X", "username":"myUsername", "password":"myPassword" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"result": {
"txID": "LWTRsiKnEUJC58y8ezAk6hhzmSMUCtemLvm3LZFw8fxDQpns3"
},
"id": 1
}
djtx.importKey#
caution
Not recommended for use on Mainnet. See warning notice in Keystore API.
Give a user control over an address by providing the private key that controls the address.
Signature:
djtx.importKey({ username: string, password:string, privateKey:string }) -> {address: string}
Request:
- Add
privateKeytousername's set of private keys.
Response:
addressis the addressusernamenow controls with the private key. It will be in hex format.
Example Call to run:
curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"djtx.importKey", "params" :{ "username" :"myUsername", "password":"myPassword", "privateKey":"PrivateKey-2o2uPgTSf3aR5nW6yLHjBEAiatAFKEhApvYzsjvAJKRXVWCYkE" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"result": {
"address": "0xc876DF0F099b3eb32cBB78820d39F5813f73E18C"
},
"id": 1
}
djtx.issueTx#
Send a signed transaction to the network. encoding specifies the format of the signed transaction.
Can only be hex when a value is provided.
Signature:
djtx.issueTx({ tx: string, encoding: string, //optional }) -> { txID: string }
Example Call:
curl -X POST --data '{ "jsonrpc":"2.0", "id" : 1, "method" :"djtx.issueTx", "params" :{ "tx":"0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730", "encoding": "hex" } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/djtx
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"txID": "NUPLwbt2hsYxpQg4H2o451hmTWQ4JZx2zMzM4SinwtHgAdX1JLPHXvWSXEnpecStLj"
}
}
Admin API#
This API can be used for debugging. Note that the Admin API is disabled by default. To run a node
with the Admin API enabled, use Utility Chain config flag--coreth-admin-api-enabled:true.
Endpoint#
/ext/bc/C/admin
admin.setLogLevel#
Sets the log level of the Utility Chain.
Signature:
admin.setLogLevel({level:string}) -> {}
levelis the log level to be set.
Example Call:
1curl -X POST --data '{ 2 "jsonrpc":"2.0", 3 "id" :1, 4 "method" :"admin.setLogLevel", 5 "params": { 6 "level":"info" 7 } 8}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/admin
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {}
}
admin.startCPUProfiler#
Starts a CPU profile.
Signature:
admin.startCPUProfiler() -> {}
Example Call:
1curl -X POST --data '{ 2 "jsonrpc":"2.0", 3 "id" :1, 4 "method" :"admin.startCPUProfiler", 5 "params": {} 6}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/admin
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {}
}
admin.stopCPUProfiler#
Stops and writes a CPU profile.
Signature:
admin.stopCPUProfiler() -> {}
Example Call:
1curl -X POST --data '{ 2 "jsonrpc":"2.0", 3 "id" :1, 4 "method" :"admin.stopCPUProfiler", 5 "params": {} 6}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/admin
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {}
}
admin.memoryProfile#
Runs and writes a memory profile.
Signature:
admin.memoryProfile() -> {}
Example Call:
1curl -X POST --data '{ 2 "jsonrpc":"2.0", 3 "id" :1, 4 "method" :"admin.memoryProfile", 5 "params": {} 6}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/admin
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {}
}
admin.lockProfile#
Runs a mutex profile writing to the coreth_performance_c directory.
Signature:
admin.lockProfile() -> {}
Example Call:
1curl -X POST --data '{ 2 "jsonrpc":"2.0", 3 "id" :1, 4 "method" :"admin.lockProfile", 5 "params": {} 6}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/admin
Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {}
}