Starcoin vs. Ethereum - JSON RPC comparison
We have provided Ethereum and Starcoin JSON RPC API collections in this repo. You could import them and test conveniently.
- Go to Postman Workspace page, then import
ethereum.postman_collection.json
- Go to Postman Environments page, then import
ethereum.postman_environment.json
- Go to Infura.io, choose an Ethereum network(for example,
kovan
) and get yourproject_id
- Modify the network name and
project_id
in Postman ethereum Environments with your own - Choose an API, and click Send button
- Go to Postman Workspace page, then import
starcoin.postman_collection.json
- Go to Postman Environments page, then import
starcoin.postman_environment.json
- Run your local Starcoin network, or join online Starcoin network, like
barnard
, please refer to official Starcoin documentation. The difference is that here we will open all Websocket and HTTP APIs for testing. For security, please do not tell your node URL to others.
Note: if an API's response contains result: null
instead of error: {...}
, it's working as expected.
Start barnard node
./starcoin -n barnard --push-server-url http://miner-metrics-pushgw.starcoin.org:9191/ --push-interval 60 --miner-thread 4 --websocket-apis all --http-apis all
Start local dev node
./starcoin -n dev --miner-thread 2 --websocket-apis all --http-apis all
- Modify the URL in Postman starcoin environments with your own
- Choose an API, and click Send button
Ethereum | Starcoin |
---|---|
eth_accounts |
account.list |
Ethereum | Starcoin |
---|---|
eth_getBalance |
contract.get_resource -> result.value[0][1].Struct.value[0][1].U128 |
Ethereum | Starcoin |
---|---|
eth_blockNumber |
chain.info -> result.header.number |
Ethereum | Starcoin |
---|---|
eth_getBlockByNumber |
chain.get_block_by_number |
Ethereum | Starcoin |
---|---|
eth_getBlockByHash |
chain.get_block_by_hash |
Ethereum | Starcoin |
---|---|
eth_getBlockTransactionCountByHash |
chain.get_block_txn_infos -> result.length |
Note: chain.get_block_txn_infos
returns an array of all transactions on a block.
Ethereum | Starcoin |
---|---|
eth_getTransactionByHash |
chain.get_transaction |
Ethereum | Starcoin |
---|---|
eth_getTransactionByBlockHashAndIndex |
chain.get_txn_info_by_block_and_index |
Ethereum | Starcoin |
---|---|
eth_getTransactionReceipt |
chain.get_transaction |
Note: chain.get_transaction
returns information of an executed transaction. To get information of a pending transaction, please use txpool.pending_txn
.
Ethereum | Starcoin |
---|---|
eth_getTransactionCount |
state.get_account_state_set -> result[result.length - 1][1].U64 |
Note: state.get_account_state_set
returns a big array containing all information of an account, the number of transactions equals the sequence_number
of the account.
Ethereum | Starcoin |
---|---|
eth_getCode |
contract.get_code |
Note: you could get a list of Starcoin modules and their module_id here: https://github.com/starcoinorg/starcoin/tree/master/vm/stdlib/modules/doc
Ethereum | Starcoin |
---|---|
net_version |
chain.id -> result.id |
Note: eth_chainId
in Ethereum also returns the chain ID, but in hex format. The chain.id
method in Starcoin will also return the chain name of Starcoin, for example, barnard
, proxima
, etc.
Ethereum | Starcoin |
---|---|
eth_call |
txpool.submit_hex_transaction |
Note: hex transaction should be constructed from signer and transaction parameters, check the details out in starcoin.js.
Ethereum | Starcoin |
---|---|
eth_gasPrice |
txpool.gas_price |
Ethereum | Starcoin |
---|---|
net_peerCount |
network_manager.known_peers -> result.length |
Notes: node.peers
in Starcoin will also returns a big array containing all peers' information.
Ethereum | Starcoin |
---|---|
eth_syncing |
sync.status |
chain.get_blocks_by_number
chain.get_transaction_info
eth_estimateGas
eth_getBlockTransactionCountByNumber
eth_getTransactionByBlockNumberAndIndex