Documentation ¶
Overview ¶
Introduction ¶
Justitia RPC is built using our own RPC library which contains its own set of documentation and tests. See it here: https://github.com/DSiSc/apigateway/tree/master/rpc/lib
Or resort to the rpc documentation at: https://dsisc.github.io/slate/
Endpoints ¶
Index ¶
- Constants
- Variables
- func Accounts() ([]types.Address, error)
- func AddTestRoutes()
- func BlockNumber() (*cmn.Uint64, error)
- func Call(args ctypes.SendTxArgs, blockNr types.BlockNumber) (cmn.Bytes, error)
- func ChannelInfo() ([]ctypes.ChannelInfo, error)
- func EstimateGas(args ctypes.SendTxArgs) (cmn.Uint64, error)
- func GasPrice() (*cmn.Big, error)
- func GetBalance(address apitypes.Address, blockNr apitypes.BlockNumber) (*cmn.Big, error)
- func GetBlockByHash(blockHash cmn.Hash, fullTx bool) (*rpctypes.Blockdata, error)
- func GetBlockByNumber(blockNr apitypes.BlockNumber, fullTx bool) (*rpctypes.Blockdata, error)
- func GetBlockTransactionCountByHash(blockHash cmn.Hash) (*cmn.Uint, error)
- func GetBlockTransactionCountByNumber(blockNr apitypes.BlockNumber) (*cmn.Uint, error)
- func GetCode(address apitypes.Address, blockNr apitypes.BlockNumber) (*cmn.Bytes, error)
- func GetTransactionByBlockHashAndIndex(blockHash cmn.Hash, index cmn.Uint) (*ctypes.RPCTransaction, error)
- func GetTransactionByBlockNumberAndIndex(blockNr types.BlockNumber, index cmn.Uint) (*ctypes.RPCTransaction, error)
- func GetTransactionByHash(hash cmn.Hash) (*ctypes.RPCTransaction, error)
- func GetTransactionCount(address apitypes.Address, blockNr apitypes.BlockNumber) (*cmn.Uint64, error)
- func GetTransactionReceipt(hash cmn.Hash) (*ctypes.RPCReceipt, error)
- func Listening() (bool, error)
- func Logs(wsCtx rpctypes.WSRPCContext, rawMsg json.RawMessage) (string, error)
- func NewHeaders(wsCtx rpctypes.WSRPCContext) (string, error)
- func NewPendingTransactions(wsCtx rpctypes.WSRPCContext) (string, error)
- func NodeInfo() ([]ctypes.NodeInfo, error)
- func RPCMarshalBlock(b *types.Block, inclTx bool, fullTx bool) (*rpctypes.Blockdata, error)
- func ReceiveCrossRawTransactionReq(encodedTx acmn.Bytes) (cmn.Hash, error)
- func SendCrossRawTransaction(encodedTx acmn.Bytes, url string) (cmn.Hash, error)
- func SendRawTransaction(encodedTx acmn.Bytes) (cmn.Hash, error)
- func SendTransaction(args ctypes.SendTxArgs) (cmn.Hash, error)
- func SetSwCh(ch chan<- interface{})
- func Subscribe(wsCtx rpctypes.WSRPCContext, rawMsg []json.RawMessage) (string, error)
- func TypeConvert(a *cmn.Hash) types.Hash
- func UnSubscribe(wsCtx rpctypes.WSRPCContext, subID string) (bool, error)
- func Version() (string, error)
- type FilterCriteria
- type ResultEcho
- type StringArgs
Constants ¶
const ( NewHeadersEvent = "newHeads" LogsEvent = "logs" NewPendingTransactionsEvent = "newPendingTransactions" SyncingEvent = "syncing" )
Variables ¶
var Routes = map[string]*rpc.RPCFunc{ "eth_sendTransaction": rpc.NewRPCFunc(SendTransaction, "args"), "eth_sendRawTransaction": rpc.NewRPCFunc(SendRawTransaction, "encodedTx"), "eth_sendCrossRawTransaction": rpc.NewRPCFunc(SendCrossRawTransaction, "encodedTx, url"), "eth_receiveCrossRawTransactionReq": rpc.NewRPCFunc(ReceiveCrossRawTransactionReq, "encodedTx"), "eth_getBlockByHash": rpc.NewRPCFunc(GetBlockByHash, "blockHash, fullTx"), "eth_getBlockByNumber": rpc.NewRPCFunc(GetBlockByNumber, "blockNr, fullTx"), "eth_getTransactionByHash": rpc.NewRPCFunc(GetTransactionByHash, "hash"), "eth_getTransactionReceipt": rpc.NewRPCFunc(GetTransactionReceipt, "hash"), "eth_getBlockTransactionCountByHash": rpc.NewRPCFunc(GetBlockTransactionCountByHash, "blockHash"), "eth_getBlockTransactionCountByNumber": rpc.NewRPCFunc(GetBlockTransactionCountByNumber, "blockNr"), "eth_blockNumber": rpc.NewRPCFunc(BlockNumber, ""), "eth_getBalance": rpc.NewRPCFunc(GetBalance, "address, blockNr"), "eth_getCode": rpc.NewRPCFunc(GetCode, "address, blockNr"), "eth_getTransactionCount": rpc.NewRPCFunc(GetTransactionCount, "address, blockNr"), "eth_getTransactionByBlockHashAndIndex": rpc.NewRPCFunc(GetTransactionByBlockHashAndIndex, "blockHash, index"), "eth_getTransactionByBlockNumberAndIndex": rpc.NewRPCFunc(GetTransactionByBlockNumberAndIndex, "blockNr, index"), "eth_call": rpc.NewRPCFunc(Call, "args, blockNr"), "eth_gasPrice": rpc.NewRPCFunc(GasPrice, ""), "eth_estimateGas": rpc.NewRPCFunc(EstimateGas, "args"), "eth_accounts": rpc.NewRPCFunc(Accounts, ""), "eth_subscribe": rpc.NewWSRPCFunc(Subscribe, "rawMsg"), "eth_unsubscribe": rpc.NewWSRPCFunc(UnSubscribe, "subID"), "net_listening": rpc.NewRPCFunc(Listening, ""), "net_version": rpc.NewRPCFunc(Version, ""), "net_nodeInfo": rpc.NewRPCFunc(NodeInfo, ""), "net_channelInfo": rpc.NewRPCFunc(ChannelInfo, ""), }
NOTE: Amino is registered in rpc/core/types/wire.go.
Functions ¶
func AddTestRoutes ¶
func AddTestRoutes()
func BlockNumber ¶
#### eth_blockNumber
Returns the number of most recent block.
##### Parameters none
##### Returns
`QUANTITY` - integer of the current block number the client is on.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}'
// Result
{ "id":83, "jsonrpc": "2.0", "result": "0xc94" // 1207 }
```
***
func Call ¶
func Call(args ctypes.SendTxArgs, blockNr types.BlockNumber) (cmn.Bytes, error)
#### eth_call
Executes a new message call immediately without creating a transaction on the block chain.
##### Parameters
1. `Object` - The transaction call object - `from`: `DATA`, 20 Bytes - (optional) The address the transaction is sent from. - `to`: `DATA`, 20 Bytes - The address the transaction is directed to. - `gas`: `QUANTITY` - (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions. - `gasPrice`: `QUANTITY` - (optional) Integer of the gasPrice used for each paid gas - `value`: `QUANTITY` - (optional) Integer of the value sent with this transaction - `data`: `DATA` - (optional) Hash of the method signature and encoded parameters. For details see [Ethereum Contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) 2. `QUANTITY|TAG` - integer block number, or the string `"latest"`, `"earliest"` or `"pending"`, see the [default block parameter](#the-default-block-parameter)
##### Returns
`DATA` - the return value of executed contract.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{see above}],"id":1}'
// Result
{ "id":1, "jsonrpc": "2.0", "result": "0x" }
```
***
func ChannelInfo ¶
func ChannelInfo() ([]ctypes.ChannelInfo, error)
func EstimateGas ¶
func EstimateGas(args ctypes.SendTxArgs) (cmn.Uint64, error)
#### eth_estimateGas
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.
##### Parameters
See [eth_call](#eth_call) parameters, expect that all properties are optional. If no gas limit is specified geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit.
##### Returns
`QUANTITY` - the amount of gas used.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{see above}],"id":1}'
// Result
{ "id":1, "jsonrpc": "2.0", "result": "0x5208" // 21000 }
```
***
func GasPrice ¶
#### eth_gasPrice
Returns the current price per gas in wei.
##### Parameters none
##### Returns
`QUANTITY` - integer of the current gas price in wei.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":73}'
// Result
{ "id":73, "jsonrpc": "2.0", "result": "0x09184e72a000" // 10000000000000 }
```
***
func GetBalance ¶
#### eth_getBalance
Returns the balance of the account of given address.
##### Parameters
1. `DATA`, 20 Bytes - address to check for balance. 2. `QUANTITY|TAG` - integer block number, or the string `"latest"`, `"earliest"` or `"pending"`, see the [default block parameter](#the-default-block-parameter)
```js params: [
'0xc94770007dda54cF92009BFF0dE90c06F603a09f', 'latest'
] ```
##### Returns
`QUANTITY` - integer of the current balance in wei.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],"id":1}'
// Result
{ "id":1, "jsonrpc": "2.0", "result": "0x0234c8a3397aab58" // 158972490234375000 }
```
***
func GetBlockByHash ¶
#### eth_getBlockByHash
Returns information about a block by hash.
##### Parameters
1. `DATA`, 32 Bytes - Hash of a block. 2. `Boolean` - If `true` it returns the full transaction objects, if `false` only the hashes of the transactions.
```js params: [
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331', true
] ```
##### Returns
`Object` - A block object, or `null` when no block was found:
- `number`: `QUANTITY` - the block number. `null` when its pending block. - `hash`: `DATA`, 32 Bytes - hash of the block. `null` when its pending block. - `parentHash`: `DATA`, 32 Bytes - hash of the parent block. - `transactionsRoot`: `DATA`, 32 Bytes - the root of the transaction trie of the block. - `stateRoot`: `DATA`, 32 Bytes - the root of the final state trie of the block. - `receiptsRoot`: `DATA`, 32 Bytes - the root of the receipts trie of the block. - `miner`: `DATA`, 20 Bytes - the address of the beneficiary to whom the mining rewards were given. - `timestamp`: `QUANTITY` - the unix timestamp for when the block was collated. - `transactions`: `Array` - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true],"id":1}'
// Result { "id":1, "jsonrpc":"2.0",
"result": { "number": "0x1b4", // 436 "hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", "parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5", "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff", "miner": "0x4e65fda2159562a496f9f3522f89122a3088497a", "timestamp": "0x54e34e8e" // 1424182926 "transactions": [{...},{ ... }] } }
```
***
func GetBlockByNumber ¶
#### eth_getBlockByNumber
Returns information about a block by block number.
##### Parameters
1. `QUANTITY|TAG` - integer of a block number, or the string `"earliest"`, `"latest"` or `"pending"`, as in the [default block parameter](#the-default-block-parameter). 2. `Boolean` - If `true` it returns the full transaction objects, if `false` only the hashes of the transactions.
```js params: [
'0x1b4', // 436 true
] ```
##### Returns
See [eth_getBlockByHash](#eth_getblockbyhash)
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":1}' ```
Result see [eth_getBlockByHash](#eth_getblockbyhash)
***
func GetBlockTransactionCountByHash ¶
#### eth_getBlockTransactionCountByHash
Returns the number of transactions in a block from a block matching the given block hash.
##### Parameters
1. `DATA`, 32 Bytes - hash of a block.
```js params: [
'0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
] ```
##### Returns
`QUANTITY` - integer of the number of transactions in this block.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f"],"id":1}'
// Result
{ "id":1, "jsonrpc": "2.0", "result": "0xc" // 11 }
```
***
func GetBlockTransactionCountByNumber ¶
func GetBlockTransactionCountByNumber(blockNr apitypes.BlockNumber) (*cmn.Uint, error)
#### eth_getBlockTransactionCountByNumber > > Returns the number of transactions in a block matching the given block number.
##### Parameters
1. `QUANTITY|TAG` - integer of a block number, or the string `"earliest"`, `"latest"` or `"pending"`, as in the [default block parameter](#the-default-block-parameter).
```js params: [
'0xe8', // 232
] ```
##### Returns
`QUANTITY` - integer of the number of transactions in this block.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["0xe8"],"id":1}'
// Result
{ "id":1, "jsonrpc": "2.0", "result": "0xa" // 10 }
```
***
func GetCode ¶
#### eth_getCode
Returns code at a given address.
##### Parameters
1. `DATA`, 20 Bytes - address. 2. `QUANTITY|TAG` - integer block number, or the string `"latest"`, `"earliest"` or `"pending"`, see the [default block parameter](#the-default-block-parameter).
```js params: [
'0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b', '0x2' // 2
] ```
##### Returns
`DATA` - the code from the given address.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x2"],"id":1}'
// Result
{ "id":1, "jsonrpc": "2.0", "result": "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056" }
```
***
func GetTransactionByBlockHashAndIndex ¶
func GetTransactionByBlockHashAndIndex(blockHash cmn.Hash, index cmn.Uint) (*ctypes.RPCTransaction, error)
Result see [eth_getTransactionByHash](#eth_gettransactionbyhash) ***
func GetTransactionByBlockNumberAndIndex ¶
func GetTransactionByBlockNumberAndIndex(blockNr types.BlockNumber, index cmn.Uint) (*ctypes.RPCTransaction, error)
#### eth_getTransactionByBlockNumberAndIndex
Returns information about a transaction by block number and transaction index position.
##### Parameters
1. `QUANTITY|TAG` - a block number, or the string `"earliest"`, `"latest"` or `"pending"`, as in the [default block parameter](#the-default-block-parameter). 2. `QUANTITY` - the transaction index position.
```js params: [
'0x29c', // 668 '0x0' // 0
] ```
##### Returns
See [eth_getTransactionByHash](#eth_gettransactionbyhash)
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x29c", "0x0"],"id":1}' ```
Result see [eth_getTransactionByHash](#eth_gettransactionbyhash)
***
func GetTransactionByHash ¶
func GetTransactionByHash(hash cmn.Hash) (*ctypes.RPCTransaction, error)
#### eth_getTransactionByHash
Returns the information about a transaction requested by transaction hash.
##### Parameters
1. `DATA`, 32 Bytes - hash of a transaction
```js params: [
"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
] ```
##### Returns
`Object` - A transaction object, or `null` when no transaction was found:
- `blockHash`: `DATA`, 32 Bytes - hash of the block where this transaction was in. `null` when its pending. - `blockNumber`: `QUANTITY` - block number where this transaction was in. `null` when its pending. - `from`: `DATA`, 20 Bytes - address of the sender. - `gas`: `QUANTITY` - gas provided by the sender. - `gasPrice`: `QUANTITY` - gas price provided by the sender in Wei. - `hash`: `DATA`, 32 Bytes - hash of the transaction. - `input`: `DATA` - the data send along with the transaction. - `nonce`: `QUANTITY` - the number of transactions made by the sender prior to this one. - `to`: `DATA`, 20 Bytes - address of the receiver. `null` when its a contract creation transaction. - `transactionIndex`: `QUANTITY` - integer of the transactions index position in the block. `null` when its pending. - `value`: `QUANTITY` - value transferred in Wei. - `v`: `QUANTITY` - ECDSA recovery id - `r`: `DATA`, 32 Bytes - ECDSA signature r - `s`: `DATA`, 32 Bytes - ECDSA signature s
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"],"id":1}'
// Result
{ "jsonrpc":"2.0", "id":1, "result":{ "blockHash":"0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2", "blockNumber":"0x5daf3b", // 6139707 "from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d", "gas":"0xc350", // 50000 "gasPrice":"0x4a817c800", // 20000000000 "hash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b", "input":"0x68656c6c6f21", "nonce":"0x15", // 21 "to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb", "transactionIndex":"0x41", // 65 "value":"0xf3dbb76162000", // 4290000000000000 "v":"0x25", // 37 "r":"0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea", "s":"0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c" } }
``` ***
func GetTransactionCount ¶
func GetTransactionCount(address apitypes.Address, blockNr apitypes.BlockNumber) (*cmn.Uint64, error)
#### eth_getTransactionCount
Returns the number of transactions *sent* from an address.
##### Parameters
1. `DATA`, 20 Bytes - address. 2. `QUANTITY|TAG` - integer block number, or the string `"latest"`, `"earliest"` or `"pending"`, see the [default block parameter](#the-default-block-parameter)
```js params: [
'0xc94770007dda54cF92009BFF0dE90c06F603a09f', 'latest' // state at the latest block
] ```
##### Returns
`QUANTITY` - integer of the number of transactions send from this address.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f","latest"],"id":1}'
// Result
{ "id":1, "jsonrpc": "2.0", "result": "0x1" // 1 }
```
***
func GetTransactionReceipt ¶
func GetTransactionReceipt(hash cmn.Hash) (*ctypes.RPCReceipt, error)
#### eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
**Note** That the receipt is not available for pending transactions.
##### Parameters
1. `DATA`, 32 Bytes - hash of a transaction
```js params: [
'0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
] ```
##### Returns
`Object` - A transaction receipt object, or `null` when no receipt was found:
- `transactionHash `: `DATA`, 32 Bytes - hash of the transaction. - `transactionIndex`: `QUANTITY` - integer of the transactions index position in the block. - `blockHash`: `DATA`, 32 Bytes - hash of the block where this transaction was in. - `blockNumber`: `QUANTITY` - block number where this transaction was in. - `from`: `DATA`, 20 Bytes - address of the sender. - `to`: `DATA`, 20 Bytes - address of the receiver. null when its a contract creation transaction. - `cumulativeGasUsed `: `QUANTITY ` - The total amount of gas used when this transaction was executed in the block. - `gasUsed `: `QUANTITY ` - The amount of gas used by this specific transaction alone. - `contractAddress `: `DATA`, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise `null`. - `logs`: `Array` - Array of log objects, which this transaction generated. - `logsBloom`: `DATA`, 256 Bytes - Bloom filter for light clients to quickly retrieve related logs.
It also returns _either_ :
- `root` : `DATA` 32 bytes of post-transaction stateroot (pre Byzantium) - `status`: `QUANTITY` either `1` (success) or `0` (failure)
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'
// Result { "id":1, "jsonrpc":"2.0",
"result": { transactionHash: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', transactionIndex: '0x1', // 1 blockNumber: '0xb', // 11 blockHash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b', cumulativeGasUsed: '0x33bc', // 13244 gasUsed: '0x4dc', // 1244 contractAddress: '0xb60e8dd61c5d32be8058bb8eb970870f07233155', // or null, if none was created logs: [{ // logs as returned by getFilterLogs, etc. }, ...], logsBloom: "0x00...0", // 256 byte bloom filter status: '0x1' } }
``` ***
func Logs ¶ added in v1.0.0
func Logs(wsCtx rpctypes.WSRPCContext, rawMsg json.RawMessage) (string, error)
Logs subscribe new logs event
func NewHeaders ¶ added in v1.0.0
NewHeaders subscribe new headers event
func NewPendingTransactions ¶ added in v1.0.0
NewPendingTransactions subscribe new transactions event
func RPCMarshalBlock ¶
func ReceiveCrossRawTransactionReq ¶ added in v1.1.0
func SendCrossRawTransaction ¶ added in v1.1.0
func SendRawTransaction ¶ added in v1.0.0
Use [eth_getTransactionReceipt](#eth_gettransactionreceipt) to get the contract address, after the transaction was mined, when you created a contract.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":[{see above}],"id":1}'
// Result { "id":1, "jsonrpc": "2.0", "result": "0x919d38fa5c395fa0f677e6554eef74fc7a48a64c087e320d538114c714d67d8f" } ```
***
func SendTransaction ¶
func SendTransaction(args ctypes.SendTxArgs) (cmn.Hash, error)
#### eth_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
##### Parameters
1. `Object` - The transaction object - `from`: `DATA`, 20 Bytes - The address the transaction is send from. - `to`: `DATA`, 20 Bytes - (optional when creating new contract) The address the transaction is directed to. - `gas`: `QUANTITY` - (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas. - `gasPrice`: `QUANTITY` - (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas - `value`: `QUANTITY` - (optional) Integer of the value sent with this transaction - `data`: `DATA` - The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see [Ethereum Contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) - `nonce`: `QUANTITY` - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
```js
params: [{ "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155", "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567", "gas": "0x76c0", // 30400 "gasPrice": "0x9184e72a000", // 10000000000000 "value": "0x9184e72a", // 2441406250 "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675" }]
```
##### Returns
`DATA`, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use [eth_getTransactionReceipt](#eth_gettransactionreceipt) to get the contract address, after the transaction was mined, when you created a contract.
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{see above}],"id":1}'
// Result
{ "id":1, "jsonrpc": "2.0", "result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331" }
```
***
func Subscribe ¶ added in v1.0.0
func Subscribe(wsCtx rpctypes.WSRPCContext, rawMsg []json.RawMessage) (string, error)
#### eth_subscribe
Subscribe for events(newHeads/logs/newPendingTransactions) via WebSocket.
##### Parameters
1. `TAG` - subscription name `"newHeads"`, `"logs"` or `"newPendingTransactions"`(newHeads: new header is appended to the chain; logs: new logs are included in new blocks; newPendingTransactions: new transactions are added to the pending state and are signed with a key that is available in the node). 2. `Object` - the transaction index position.
```js params: [
'0x29c', // 668 '0x0' // 0
] ```
##### Returns
subscription id
##### Example ```js // Request curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x29c", "0x0"],"id":1}' ```
Result see [eth_getTransactionByHash](#eth_gettransactionbyhash)
*** Subscribe for events via WebSocket.
func UnSubscribe ¶ added in v1.0.0
Subscribe for events via WebSocket.
Types ¶
type FilterCriteria ¶ added in v1.0.0
type FilterCriteria struct { BlockHash *crafttypes.Hash `json:"block_hash"` // used by eth_getLogs, return logs only from block with this hash FromBlock *big.Int `json:"from_block"` // beginning of the queried range, nil means genesis block ToBlock *big.Int `json:"to_block"` // end of the range, nil means latest block Addresses []crafttypes.Address `json:"addresses"` // restricts matches to events created by specific contracts // The Topic list restricts matches to particular event topics. Each event has a list // of topics. Topics matches a prefix of that list. An empty element slice matches any // topic. Non-empty elements represent an alternative that matches any of the // contained topics. // // Examples: // {} or nil matches any topic list // {{A}} matches topic A in first position // {{}, {B}} matches any topic in first position AND B in second position // {{A}, {B}} matches topic A in first position AND B in second position // {{A, B}, {C, D}} matches topic (A OR B) in first position AND (C OR D) in second position Topics [][]crafttypes.Hash `json:"topics"` }
FilterCriteria contains options for contract log filtering.
type ResultEcho ¶
type ResultEcho struct {
Value string `json:"value"`
}
func EchoResult ¶
func EchoResult(v string) (*ResultEcho, error)
func EchoResultArgs ¶
func EchoResultArgs(v ctypes.StringArgs) (*ResultEcho, error)
type StringArgs ¶
type StringArgs struct {
From string `json:"from"`
}