Skip to content

Account

Account RPC interface

Address management and initiate simple transactions

1. account_listAddress

  • Usage:

  Lists all local addresses

  • Params:

   null

  • Return:Address of the array

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_listAddress","params":[], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_listAddress 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":["0x3296d3336895b5baaa0eca3df911741bd0681c3f","0x3ebcbe7cb440dd8c52940a2963472380afbb56c5"]}

2. account_createAccount

  • Usage:

  Create a local account

  • Params:

   1. password

  • Return:New account address information

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_createAccount","params":["123456"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_createAccount 123456 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x2944c15c466fad03ec1282bab579dec5a0cf0fa3"}

3. account_createWallet

  • Usage:

  Create a local wallet

  • Params:

   1. The wallet password

  • Return:Failure returns the reason for the error, and success returns no information

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_createWallet","params":["123"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_createWallet 123 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":None}

4. account_lockAccount

  • Usage:

  Lock the account

  • Params:

   null

  • Return:Failure returns the reason for the error, and success returns no information

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_lockAccount","params":["0x518b3fefa3fb9a72753c6ad10a2b68cc034ec391"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_lockAccount 0x518b3fefa3fb9a72753c6ad10a2b68cc034ec391 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":None}

5. account_unlockAccount

  • Usage:

  Unlock the account

  • Params:

   1. The account address
   2. password

  • Return:Failure returns the reason for the error, and success returns no information

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_unlockAccount","params":["0x518b3fefa3fb9a72753c6ad10a2b68cc034ec391", "123456"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_unlockAccount 0x518b3fefa3fb9a72753c6ad10a2b68cc034ec391 123456 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":None}

6. account_openWallet

  • Usage:

  Open my wallet

  • Params:

   1. The wallet password

  • Return:error or none

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_openWallet","params":["123"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_openWallet 123 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":None}

7. account_closeWallet

  • Usage:

  close wallet

  • Params:

   null

  • Return:none

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_closeWallet","params":[], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_closeWallet 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":None}

8. account_transfer

  • Usage:

  transfer

  • Params:

   1. The address at which the transfer was initiated
   2. Recipient's address
   3. Mount
   4. gas price
   5. gas limit
   6. commit

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_transfer","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x8a19d9949738faaecc269f0a883608a00d2db863","0x111","0x110","0x30000",""],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_transfer "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x8a19d9949738faaecc269f0a883608a00d2db863" "0x111" "0x110" "0x30000" "" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x3a3b59f90a21c2fd1b690aa3a2bc06dc2d40eb5bdc26fdd7ecb7e1105af2638e"}

9. account_transferWithNonce

  • Usage:

  transfer with nonce

  • Params:

   1. The address at which the transfer was initiated
   2. Recipient's address
   3. Mount
   4. gas price
   5. gas limit
   6. commit
   7. nonce

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_transferWithNonce","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x8a19d9949738faaecc269f0a883608a00d2db863","0x111","0x110","0x30000","",1],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_transferWithNonce "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x8a19d9949738faaecc269f0a883608a00d2db863" "0x111" "0x110" "0x30000" "" 1 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x3a3b59f90a21c2fd1b690aa3a2bc06dc2d40eb5bdc26fdd7ecb7e1105af2638e"}

10. account_setAlias

  • Usage:

  Set an alias

  • Params:

   1. address
   2. alias
   3. gas price
   4. gas lowLimit

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_setAlias","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","AAAAA","0x110","0x30000"],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_setAlias "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "AAAAA" "0x110" "0x30000" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x5adb248f2943e12fb91c140bd3d0df6237712061e9abae97345b0869c3daa749"}

11. account_voteCredit

  • Usage:

  Vote credit to candidate

  • Params:

   1. address of voter
   2. address of candidate
   3. amount
   4. gas price
   5. gas uplimit of transaction

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_voteCredit","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x111","0x110","0x30000"],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_VoteCredit "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x111" "0x110" "0x30000" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x3a3b59f90a21c2fd1b690aa3a2bc06dc2d40eb5bdc26fdd7ecb7e1105af2638e"}

12. account_cancelVoteCredit

  • Usage:

  Cancel vote credit to candidate

  • Params:

   1. address of voter
   2. address of candidate
   3. amount
   4. gas price
   5. gas limit
   6. remark

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_cancelVoteCredit","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x111","0x110","0x30000"],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_cancelVoteCredit "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x111" "0x110" "0x30000" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x3a3b59f90a21c2fd1b690aa3a2bc06dc2d40eb5bdc26fdd7ecb7e1105af2638e"}

13. account_candidateCredit

  • Usage:

  Candidate node pledge

  • Params:

   1. The address of the pledger
   2. The pledge amount
   3. gas price
   4. gas limit
   5. The pubkey corresponding to the address of the pledger, and the P2p information of the pledger

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_candidateCredit","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x111","0x110","0x30000","{\"Pubkey\":\"0x020e233ebaed5ade5e48d7ee7a999e173df054321f4ddaebecdb61756f8a43e91c\",\"Node\":\"enode://3f05da2475bf09ce20b790d76b42450996bc1d3c113a1848be1960171f9851c0@149.129.172.91:44444\"}"],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_CandidateCredit "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x111" "0x110" "0x30000" "{\"Pubkey\":\"0x020e233ebaed5ade5e48d7ee7a999e173df054321f4ddaebecdb61756f8a43e91c\" \"Node\":\"enode://3f05da2475bf09ce20b790d76b42450996bc1d3c113a1848be1960171f9851c0@149.129.172.91:44444\"}" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x3a3b59f90a21c2fd1b690aa3a2bc06dc2d40eb5bdc26fdd7ecb7e1105af2638e"}

14. account_cancelCandidateCredit

  • Usage:

  To cancel the candidate

  • Params:

   1. The address at which the transfer was cancel
   2. address of candidate
   3. amount
   4. gas price
   5. gas limit

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_cancelCandidateCredit","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x111","0x110","0x30000",""],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_cancelCandidateCredit "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x111" "0x110" "0x30000" "" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x3a3b59f90a21c2fd1b690aa3a2bc06dc2d40eb5bdc26fdd7ecb7e1105af2638e"}

15. account_readContract

  • Usage:

  Read smart contract (no data modified)

  • Params:

   1. The account address of the transaction
   2. Contract address
   3. Contract api

  • Return:The query results

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_readContract","params":["0xec61c03f719a5c214f60719c3f36bb362a202125","0xecfb51e10aa4c146bf6c12eee090339c99841efc","0x6d4ce63c"],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_readContract "0xec61c03f719a5c214f60719c3f36bb362a202125" "0xecfb51e10aa4c146bf6c12eee090339c99841efc" "0x6d4ce63c" 3
  • Response:
{"jsonrpc": "2.0", "id": 3, "result": "0x0000000000000000000000000000000000000000000000000000000000000001"}

16. account_estimateGas

  • Usage:

  Estimate how much gas is needed for the transaction

  • Params:

   1. The address at which the transfer was initiated
   2. amount
   3. commit
   4. Address of recipient

  • Return:Evaluate the result, failure returns an error

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_estimateGas","params":["0xec61c03f719a5c214f60719c3f36bb362a202125","0xecfb51e10aa4c146bf6c12eee090339c99841efc","0x6d4ce63c","0x110","0x30000"],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_estimateGas "0xec61c03f719a5c214f60719c3f36bb362a202125" "0xecfb51e10aa4c146bf6c12eee090339c99841efc" "0x6d4ce63c" "0x110" "0x30000" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x5d74aba54ace5f01a5f0057f37bfddbbe646ea6de7265b368e2e7d17d9cdeb9c"}

17. account_executeContract

  • Usage:

  Execute smart contract (cause data to be modified)

  • Params:

   1. The address of the caller
   2. Contract address
   3. Contract code
   4. gas price
   5. gas limit

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_executeContract","params":["0xec61c03f719a5c214f60719c3f36bb362a202125","0xecfb51e10aa4c146bf6c12eee090339c99841efc","0x6d4ce63c","0x110","0x30000"],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_executeContract "0xec61c03f719a5c214f60719c3f36bb362a202125" "0xecfb51e10aa4c146bf6c12eee090339c99841efc" "0x6d4ce63c" "0x110" "0x30000" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x5d74aba54ace5f01a5f0057f37bfddbbe646ea6de7265b368e2e7d17d9cdeb9c"}

18. account_createCode

  • Usage:

  Deployment of contract

  • Params:

   1. The account address of the deployment contract
   2. Content of the contract
   3. gas price
   4. gas limit

  • Return:transaction hash

  • Example:

shell:

curl -H "Content-Type: application/json" -X post --data '{"jsonrpc":"2.0","method":"account_createCode","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5","0x608060405234801561001057600080fd5b5061018c806100206000396000f3fe608060405260043610610051576000357c0100000000000000000000000000000000000000000000000000000000900480634f2be91f146100565780636d4ce63c1461006d578063db7208e31461009e575b600080fd5b34801561006257600080fd5b5061006b6100dc565b005b34801561007957600080fd5b5061008261011c565b604051808260070b60070b815260200191505060405180910390f35b3480156100aa57600080fd5b506100da600480360360208110156100c157600080fd5b81019080803560070b9060200190929190505050610132565b005b60016000808282829054906101000a900460070b0192506101000a81548167ffffffffffffffff021916908360070b67ffffffffffffffff160217905550565b60008060009054906101000a900460070b905090565b806000806101000a81548167ffffffffffffffff021916908360070b67ffffffffffffffff1602179055505056fea165627a7a723058204b651e4313ab6bc4eda61084cac1f805699cefbb979ddfd3a2d7f970903307cd0029","0x111","0x110","0x30000"],"id":3}' http://127.0.0.1:10085

cli:

drep-cli 127.0.0.1:10085 account_createCode "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x608060405234801561001057600080fd5b5061018c806100206000396000f3fe608060405260043610610051576000357c0100000000000000000000000000000000000000000000000000000000900480634f2be91f146100565780636d4ce63c1461006d578063db7208e31461009e575b600080fd5b34801561006257600080fd5b5061006b6100dc565b005b34801561007957600080fd5b5061008261011c565b604051808260070b60070b815260200191505060405180910390f35b3480156100aa57600080fd5b506100da600480360360208110156100c157600080fd5b81019080803560070b9060200190929190505050610132565b005b60016000808282829054906101000a900460070b0192506101000a81548167ffffffffffffffff021916908360070b67ffffffffffffffff160217905550565b60008060009054906101000a900460070b905090565b806000806101000a81548167ffffffffffffffff021916908360070b67ffffffffffffffff1602179055505056fea165627a7a723058204b651e4313ab6bc4eda61084cac1f805699cefbb979ddfd3a2d7f970903307cd0029" "0x111" "0x110" "0x30000" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x80d40eec443a5c3c5d24ff94179874fcf6c6f1e97284cc13b9173e36ee8040c2"}

19. account_dumpPrivkey

  • Usage:

  The private key corresponding to the export address

  • Params:

   1. address

  • Return:private key

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_dumpPrivkey","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_dumpPrivkey 0x3ebcbe7cb440dd8c52940a2963472380afbb56c5 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x270f4b122603999d1c07aec97e972a2ddf7bd8b5bfe3543c10814e6a19f13aaf"}

20. account_dumpPubkey

  • Usage:

  Export the public key corresponding to the address

  • Params:

   1. address

  • Return:public key

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_dumpPubkey","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_DumpPubkey "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x270f4b122603999d1c07aec97e972a2ddf7bd8b5bfe3543c10814e6a19f13aaf"}

21. account_sign

  • Usage:

  Signature transaction

  • Params:

   1. account of sig
   2. msg for sig

  • Return:private key

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_sign","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5", "0x00001c9b8c8fdb1f53faf02321f76253704123e2b56cce065852bab93e526ae2"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_sign "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" "0x00001c9b8c8fdb1f53faf02321f76253704123e2b56cce065852bab93e526ae2" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x1f1d16412468dd9b67b568d31839ac608bdfddf2580666db4d364eefbe285fdaed569a3c8fa1decfebbfa0ed18b636059dbbf4c2106c45fc8846909833ef2cb1de"}

22. account_generateAddresses

  • Usage:

  Generate the addresses of the other chains

  • Params:

   1. address of drep

  • Return:{BTCaddress, ethAddress, neoAddress}

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_generateAddresses","params":["0x3ebcbe7cb440dd8c52940a2963472380afbb56c5"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_generateAddresses "0x3ebcbe7cb440dd8c52940a2963472380afbb56c5" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":""}

23. account_importKeyStore

  • Usage:

  import keystore

  • Params:

   1. path
   2. password

  • Return:address list

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_importKeyStore","params":["path","123"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_importKeyStore "path" "123" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":["0x4082c96e38def8f3851831940485066234fe07b8"]}

24. account_importPrivkey

  • Usage:

  import private key

  • Params:

   1. privkey(compress hex)
   2. password

  • Return:address

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_importPrivkey","params":["0xe5510b32854ca52e7d7d41bb3196fd426d551951e2fd5f6b559a62889d87926c"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_importPrivkey "0xe5510b32854ca52e7d7d41bb3196fd426d551951e2fd5f6b559a62889d87926c" 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"0x748eb65493a964e568800c3c2885c63a0de9f9ae"}

25. account_getKeyStores

  • Usage:

  get ketStores path

  • Params:

   null

  • Return:path of keystore

  • Example:

shell:

curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"account_getKeyStores","params":[], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 account_getKeyStores 3
  • Response:
{"jsonrpc":"2.0","id":3,"result":"'path of keystores is: C:\\Users\\Kun\\AppData\\Local\\Drep\\keystore'"}