post https://{network}.unifra.io/v1/
Virtually executes a transaction, returns an estimate for the size of storage collateralized and the gas used by the transaction. The transaction will not be added to the blockchain.
Parameters
- Object - a call request object:
- from: BASE32 - (optional, default: random address) Address of sender.
- to: BASE32 - (optional, default: null for contract creation) Address of receiver.
- gasPrice: QUANTITY - (optional, default: 0) Gas price provided by the sender in Drip.
- gas: QUANTITY - (optional, default: 500000000) Gas provided by the sender.
- value: QUANTITY - (optional, default: 0) Value transferred in Drip.
- data: DATA - (optional, default: 0x) The data send along with the transaction.
- nonce: QUANTITY - (optional, default: 0) The number of transactions made by the sender prior to this one.
- QUANTITY|TAG - (optional, default: "latest_state") Integer epoch number, or the string "latest_state", "latest_confirmed", "latest_checkpoint" or "earliest", see the epoch number parameter
Returns
Object - an estimate result object:
- gasLimit: QUANTITY - The recommended gas_limit.
- gasUsed: QUANTITY - Gas used during execution.
- storageCollateralized: QUANTITY - Size of storage collateralized, in bytes.
Example
Request
curl -X POST \
--data '{"jsonrpc":"2.0","method": "cfx_estimateGasAndCollateral",
"params": [
{
"from": "cfx:aatmuv92xj87ptxg6mr11c5amug2kv6ra21g7pbbrp",
"to": "cfx:achc8nxj7r451c223m18w2dwjnmhkd6rxawrvkvsy2",
"data": "0x9bd9bbc60000000000000000000000008e45db7d866eb1a54992b24d2a8f45d53998100c0000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000101130e9d3b904b18586db51cc2db1559d47610e0000000000000000000000001ea847f89a3dd63e66e29b7b8b60540d84c78d0600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000429d069189e000000000000000000000000000000000000000000000000000006f05b59d3b20000",
"gasPrice": "0x1"
}
],"id":1}' \
-H "Content-Type: application/json" \
https://cfx-core.unifra.io/v1/ad2eb3c7a9404cc6a35a6641eaf70577
Result
{
"jsonrpc": "2.0",
"result": {
"gasLimit": "0x211a5",
"gasUsed": "0x211a5",
"storageCollateralized": "0x0"
},
"id": 0
}