📝
smartbch
  • Introduction
  • Whitepaper
  • FAQ
  • Mainnet
  • Testnets
  • Join Amber testnet as a Validator
  • Developer's Guide
    • Introduction
    • Deploy contracts using Truffle
    • Deploy contracts using Remix
    • JSON-RPC Endpoints
    • Staking Scheme
    • XHedge Smart Contract
    • Decision of the minimum gas price
  • Sha-Gate Bridge
    • Sha-Gate Specification
    • Sha-Gate Risk Analysis
    • Sha-Gate's Covenant
  • In-Depth Design Documents
    • Introduction
    • MoeingADS's General Ideas
    • MoeingADS's RabbitStore
    • MoeingADS's internal architecture
    • Benchmarking MoeingADS
    • Benchmarking MoeingEVM and MoeingADS
    • Benchmarking Testnet
    • Transaction Reordering in smartBCH
    • Transaction Parallel Execution in smartBCH
    • Send back-to-back Transactions
    • Data structures in world state
  • SmartBCH Evolution Proposals (SEPs)
    • SEP101: Store values with arbitrary length
    • SEP102: Adjustment of Used Gas
    • SEP109: On-chain Verification of Verifiable Random Functions
    • SEP18: Blockchain cheques on smartBCH
    • SEP20: Tokens on smartBCH
    • SEP206: Manipulate Native Token as a SEP20 Token
    • SEP201: Simple Stochastic Payment
  • Archives
    • Single Node Private Testnet
    • Multi-Node Testnet
    • Fake RPC Server for Testing
    • Test using MetaMask
Powered by GitBook
On this page
  • JSON-RPC smartBCH
  • Web3
  • Net
  • ETH
  • Txpool (non-standard)
  • SBCH
  • sbch_queryTxBySrc
  • sbch_queryTxByDst
  • sbch_queryTxByAddr
  • sbch_queryLogs
  • sbch_getTxListByHeight
  • sbch_getTxListByHeightWithRange
  • sbch_getAddressCount
  • sbch_getSep20AddressCount
  • sbch_getTransactionReceipt
  • sbch_validatorsInfo

Was this helpful?

  1. Developer's Guide

JSON-RPC Endpoints

PreviousDeploy contracts using RemixNextStaking Scheme

Last updated 3 years ago

Was this helpful?

JSON-RPC smartBCH

Here is a list of all the supported RPC endpoints of smartBCH, sorted by the prefixes. The endpoints with "sbch" prefix are smartBCH-specific, which are used by the . The endpoints with "web3", "net" and "eth" prefixes have the same function as infura, except for some features which are described below.

Web3

JSON-RPC methods
Doc (eth.wiki)
Doc (infura.io/docs)
Implemented?

web3_clientVersion

✅

web3_sha3

✅

Net

JSON-RPC methods
Doc (eth.wiki)
Doc (infura.io/docs)
Implemented?

net_version

✅

net_peerCount

❌

net_listening

❌

ETH

⚠️the is not supported, because the mempool of smartbchd is invisable now.

The throughput of smartBCH is very high, and no transactions will be waiting in the mempool for a long time, so there is no need to check whether a transaction is accepted by mempool.

JSON-RPC methods
Doc (eth.wiki)
Doc (infura.io/docs)
Implemented?

eth_protocolVersion

✅

eth_syncing

✅

eth_coinbase

✅ (returns 0)

eth_mining

❌

eth_hashrate

❌

eth_gasPrice

✅ (returns 0)

eth_accounts

✅

eth_blockNumber

✅

eth_getBalance

✅ ❌pending

eth_getStorageAt

✅ ❌pending

eth_getTransactionCount

✅ ❌pending

eth_getBlockTransactionCountByHash

✅

eth_getBlockTransactionCountByNumber

✅ ❌pending

eth_getUncleCountByBlockHash

❌

eth_getUncleCountByBlockNumber

❌

eth_getCode

✅ ❌pending

eth_sign

❌

eth_signTransaction

❌

eth_sendTransaction

✅

eth_sendRawTransaction

✅

eth_call

✅ ❌pending

eth_estimateGas

✅

eth_getBlockByHash

✅

eth_getBlockByNumber

✅ ❌pending

eth_getTransactionByHash

✅

eth_getTransactionByBlockHashAndIndex

✅

eth_getTransactionByBlockNumberAndIndex

✅ ❌pending

eth_getTransactionReceipt

✅

eth_getUncleByBlockHashAndIndex

❌

eth_getUncleByBlockNumberAndIndex

❌

eth_getCompiles

❌

eth_compileLLL

❌

eth_compileSolidity

❌

eth_compileSerpent

❌

eth_newFilter

✅ ❌pending

eth_newBlockFilter

✅

eth_newPendingTransactionFilter

✅

eth_uninstallFilter

✅

eth_getFilterChanges

✅

eth_getFilterLogs

✅

eth_getLogs

✅ ❌pending

eth_getWork

❌

eth_submitWork

❌

eth_submitHashrate

❌

eth_chainId

✅

eth_subscribe

https://infura.io/docs/ethereum/wss/eth-subscribe

eth_unsubscribe

https://infura.io/docs/ethereum/wss/eth-unsubscribe

Txpool (non-standard)

JSON-RPC methods
Doc
Implemented?

txpool_content

https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content

✅ (returns empty data)

txpool_status

https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_status

✅ (returns empty data)

txpool_inspect

https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_inspect

✅ (returns empty data)

SBCH

JSON-RPC methods
Doc (eth.wiki)
Doc (infura.io/docs)
Since

N/A

N/A

v0.1.0

N/A

N/A

v0.1.0

N/A

N/A

v0.1.0

N/A

N/A

v0.1.0

N/A

N/A

v0.1.0

N/A

N/A

v0.1.0

N/A

N/A

v0.1.0

N/A

N/A

v0.2.0

N/A

N/A

v0.4.0

N/A

N/A

V0.4.1

sbch_queryTxBySrc

Returns the information about transactions requested by sender address and block range.

Parameters:

  1. DATA, 20 Bytes - from address

  2. QUANTITY - integer, start number

  3. QUANTITY - integer, end number

  4. QUANTITY - integer, the maximal number of txs to return, 0 stands for default limit

Note: the start number can be greater than the end number, if so, the results will be sorted by block height in descending order.

Retrns:

sbch_queryTxByDst

Returns the information about transactions requested by recipient address and block range.

Parameters:

  1. DATA, 20 Bytes - to address

  2. QUANTITY|TAG - integer of start number, or string "latest" for the last mined block

  3. QUANTITY|TAG - integer of end number, or string "latest" for the last mined block

  4. QUANTITY - integer, the maximal number of txs to return, 0 stands for default limit

Note: the start number can be greater than the end number, if so, the results will be sorted by block height in descending order.

Retrns:

sbch_queryTxByAddr

Returns the information about transactions requested by address (sender or recipient) and block range.

Parameters:

  1. DATA, 20 Bytes - from or to address

  2. QUANTITY|TAG - integer of start number, or string "latest" for the last mined block

  3. QUANTITY|TAG - integer of end number, or string "latest" for the last mined block

  4. QUANTITY - integer, the maximal number of txs to return, 0 stands for default limit

Note: the start number can be greater than the end number, if so, the results will be sorted by block height in descending order.

Retrns:

sbch_queryLogs

Query logs by address, topics and block range. It is different from eth_getLogs in:

  1. the contract address is required, not optional;

  2. the topics are position-independent, which means as long as a log has the specified topics in any position, it will be included in the returned result.

Parameters:

  1. DATA, 20 Bytes - contract address

  2. Array of DATA, topics

  3. QUANTITY|TAG - integer of start number, or string "latest" for the last mined block

  4. QUANTITY|TAG - integer of end number, or string "latest" for the last mined block

  5. QUANTITY - integer, the maximal number of txs to return, 0 stands for default limit.

Note: the start number can be greater than the end number, if so, the results will be sorted by block height in descending order.

Returns:

sbch_getTxListByHeight

Get tx list by height.

Parameters:

  1. QUANTITY|TAG - integer of start number, or string "latest" for the last mined block

Returns:

sbch_getTxListByHeightWithRange

Get tx list by height and tx index range.

Parameters:

  1. QUANTITY|TAG - integer of start number, or string "latest" for the last mined block

  2. QUANTITY - integer of start tx index

  3. QUANTITY - integer of end tx index, or "0x0" which stands for "the largest tx index"

Returns:

sbch_getAddressCount

Returns the times addr acts as a to-address or from-address of a transaction.

Parameters:

  1. String, kind of the query, could be "from", "to", or "both"

  2. DATA, 20 Bytes - EOA or contract address

Returns:

QUANTITY - integer of count

sbch_getSep20AddressCount

Returns the times addr acts as a to-address or from-address of a SEP20 Transfer event at some contract.

Parameters:

  1. String, kind of the query, could be "from", "to", or "both"

  2. DATA, 20 Bytes - SEP20 contract address

  3. DATA, 20 Bytes - EOA or contract address

Returns:

QUANTITY - integer of count

sbch_getTransactionReceipt

Each object in internalTransactions array contains the following fields:

  • callPath: string - a string representation of call type, depth and index of internal transaction (e.g. staticcall_0_1_1).

  • from: DATA, 20 Bytes - address of the sender.

  • to: DATA, 20 Bytes - address of the receiver.

  • gas: QUANTITY - gas provided by the sender.

  • value: QUANTITY - value transferred in Wei.

  • input: DATA - the data send along with the internal transaction.

  • status: QUANTITY - either 1 (success) or 0 (failure).

  • gasUsed: QUANTITY - the amount of gas used by this internal transaction.

  • output: DATA - the data returned by the internal transaction.

  • contractAddress: DATA, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null.

sbch_validatorsInfo

Returns the validators info.

Parameters: N/A

Returns: a validator info object:

  • genesisMainnetBlockHeight: QUANTITY - The BCH mainnet height when smartbch chain mint genesis block.

  • currEpochNum: QUANTITY - The epoch number of current epoch.

  • validators: Array - Array of validator object, which mean validators created by call stakingContract.createValidator method.

  • validatorsUpdate: Array - Array of validator object, which mean validators whose voting power updated when epoch switch.

  • pendingRewards: Array - Array of pending rewards object, which mean validator pending rewards.

  • minGasPrice: QUANTITY - The minimum gas price decided in current block.

  • lastMinGasPrice: QUANTITY - The minimum gas price used in current block.

  • currValidators: Array - Array of validator object, which mean validators who on duty in current epoch.

And the validator object has fields:

  • address: DATA, 20 Bytes - Address of the validator.

  • pubkey: DATA, 32 Bytes - Consensus pubkey of the validator.

  • reward_to: DATA, 20 Bytes - Address to receive block mint rewards.

  • voting_power: QUANTITY - The minimum gas price decided in current block.

  • introduction: String - The introduction of validator.

  • staked_coins DATA, 32 Bytes - Staked coins of the validator.

  • is_retiring: Boolean - Indicate whether validator is retired.

Array - array of transaction objects, see

Array - array of transaction objects, see

Array - array of transaction objects, see

Array - array of log objects, see

Array - array of transaction objects, see

Array - array of transaction objects, see

Enhanced version of , the returned array of objects contain additional information about internal transactions.

Parameters: same as

Returns: array of objects sepcified by plus one more field of type Array: internalTransactions.

BasicBrowser
'pending' block number parameter
eth_getTransactionByHash
eth_getTransactionByHash
eth_getTransactionByHash
eth_getLogs
eth_getTransactionReceipt
eth_getTransactionReceipt
eth_getTransactionReceipt
sbch_getTransactionReceipt
sbch_getTransactionReceipt
https://eth.wiki/json-rpc/API#web3_clientVersion
https://infura.io/docs/ethereum/json-rpc/web3-clientVersion
https://eth.wiki/json-rpc/API#web3_sha3
https://eth.wiki/json-rpc/API#net_version
https://infura.io/docs/ethereum/json-rpc/net-version
https://eth.wiki/json-rpc/API#net_peercount
https://infura.io/docs/ethereum/json-rpc/net-peerCount
https://eth.wiki/json-rpc/API#net_listening
https://infura.io/docs/ethereum/json-rpc/net-listening
https://eth.wiki/json-rpc/API#eth_protocolversion
https://infura.io/docs/ethereum/json-rpc/eth-protocolVersion
https://eth.wiki/json-rpc/API#eth_syncing
https://infura.io/docs/ethereum/json-rpc/eth-syncing
https://eth.wiki/json-rpc/API#eth_coinbase
https://eth.wiki/json-rpc/API#eth_mining
https://infura.io/docs/ethereum/json-rpc/eth-mining
https://eth.wiki/json-rpc/API#eth_hashrate
https://infura.io/docs/ethereum/json-rpc/eth-hashrate
https://eth.wiki/json-rpc/API#eth_gasprice
https://infura.io/docs/ethereum/json-rpc/eth-gasPrice
https://eth.wiki/json-rpc/API#eth_accounts
https://infura.io/docs/ethereum/json-rpc/eth-accounts
https://eth.wiki/json-rpc/API#eth_blocknumber
https://infura.io/docs/ethereum/json-rpc/eth-blockNumber
https://eth.wiki/json-rpc/API#eth_getbalance
https://infura.io/docs/ethereum/json-rpc/eth-getBalance
https://eth.wiki/json-rpc/API#eth_getstorageat
https://infura.io/docs/ethereum/json-rpc/eth-getStorageAt
https://eth.wiki/json-rpc/API#eth_gettransactioncount
https://infura.io/docs/ethereum/json-rpc/eth-getTransactionCount
https://eth.wiki/json-rpc/API#eth_getblocktransactioncountbyhash
https://infura.io/docs/ethereum/json-rpc/eth-getBlockTransactionCountByHash
https://eth.wiki/json-rpc/API#eth_getblocktransactioncountbynumber
https://infura.io/docs/ethereum/json-rpc/eth-getBlockTransactionCountByNumber
https://eth.wiki/json-rpc/API#eth_getunclecountbyblockhash
https://infura.io/docs/ethereum/json-rpc/eth-getUncleCountByBlockHash
https://eth.wiki/json-rpc/API#eth_getunclecountbyblocknumber
https://infura.io/docs/ethereum/json-rpc/eth-getUncleCountByBlockNumber
https://eth.wiki/json-rpc/API#eth_getcode
https://infura.io/docs/ethereum/json-rpc/eth-getCode
https://eth.wiki/json-rpc/API#eth_sign
https://eth.wiki/json-rpc/API#eth_signtransaction
https://eth.wiki/json-rpc/API#eth_sendtransaction
https://eth.wiki/json-rpc/API#eth_sendrawtransaction
https://infura.io/docs/ethereum/json-rpc/eth-sendRawTransaction
https://eth.wiki/json-rpc/API#eth_call
https://infura.io/docs/ethereum/json-rpc/eth-call
https://eth.wiki/json-rpc/API#eth_estimategas
https://infura.io/docs/ethereum/json-rpc/eth-estimateGas
https://eth.wiki/json-rpc/API#eth_getblockbyhash
https://infura.io/docs/ethereum/json-rpc/eth-getBlockByHash
https://eth.wiki/json-rpc/API#eth_getblockbynumber
https://infura.io/docs/ethereum/json-rpc/eth-getBlockByNumber
https://eth.wiki/json-rpc/API#eth_gettransactionbyhash
https://infura.io/docs/ethereum/json-rpc/eth-getTransactionByHash
https://eth.wiki/json-rpc/API#eth_gettransactionbyblockhashandindex
https://infura.io/docs/ethereum/json-rpc/eth-getTransactionByBlockHashAndIndex
https://eth.wiki/json-rpc/API#eth_gettransactionbyblocknumberandindex
https://infura.io/docs/ethereum/json-rpc/eth-getTransactionByBlockNumberAndIndex
https://eth.wiki/json-rpc/API#eth_gettransactionreceipt
https://infura.io/docs/ethereum/json-rpc/eth-getTransactionReceipt
https://eth.wiki/json-rpc/API#eth_getunclebyblockhashandindex
https://infura.io/docs/ethereum/json-rpc/eth-getUncleByBlockHashAndIndex
https://eth.wiki/json-rpc/API#eth_getunclebyblocknumberandindex
https://infura.io/docs/ethereum/json-rpc/eth-getUncleByBlockNumberAndIndex
https://eth.wiki/json-rpc/API#eth_getcompilers
https://eth.wiki/json-rpc/API#eth_compilelll
https://eth.wiki/json-rpc/API#eth_compilesolidity
https://eth.wiki/json-rpc/API#eth_compileserpent
https://eth.wiki/json-rpc/API#eth_newfilter
https://infura.io/docs/ethereum/json-rpc/eth-newFilter
https://eth.wiki/json-rpc/API#eth_newblockfilter
https://infura.io/docs/ethereum/json-rpc/eth-newBlockFilter
https://eth.wiki/json-rpc/API#eth_newpendingtransactionfilter
https://eth.wiki/json-rpc/API#eth_uninstallfilter
https://infura.io/docs/ethereum/json-rpc/eth-uninstallFilter
https://eth.wiki/json-rpc/API#eth_getfilterchanges
https://infura.io/docs/ethereum/json-rpc/eth-getFilterChanges
https://eth.wiki/json-rpc/API#eth_getfilterlogs
https://eth.wiki/json-rpc/API#eth_getlogs
https://infura.io/docs/ethereum/json-rpc/eth-getLogs
https://eth.wiki/json-rpc/API#eth_getwork
https://infura.io/docs/ethereum/json-rpc/eth-getWork
https://eth.wiki/json-rpc/API#eth_submitwork
https://infura.io/docs/ethereum/json-rpc/eth-submitWork
https://eth.wiki/json-rpc/API#eth_submithashrate
https://infura.io/docs/ethereum/json-rpc/eth-hashrate
https://infura.io/docs/ethereum/json-rpc/eth-chainId
sbch_queryTxBySrc
sbch_queryTxByDst
sbch_queryTxByAddr
sbch_queryLogs
sbch_getTxListByHeight
sbch_getTxListByHeightWithRange
sbch_getAddressCount
sbch_getSep20AddressCount
sbch_getTransactionReceipt
sbch_validatorsInfo