[Transaction] klay_sendTransaction
Constructs a transaction with given parameters, signs the transaction with a sender's private key and propagates the transaction to Klaytn network.
klay_sendTransaction
will be failed to baobab/cypress network because it is signed in the EN node, which means that the EN must have the key that you want to sign with.
Steps to test klay_sendTransaction
.
- Step 1: Setup a local EN node
- Step 2: Create an account into the EN node
- Step 3: Unlock the account for using in signing
JSONRPC: klay_sendTransaction
Request
- application/json
Body
Array [
- TxTypeLegacyTransaction
- TxTypeValueTransfer
- TxTypeFeeDelegatedValueTransfer
- TxTypeFeeDelegatedValueTransferWithRatio
- TxTypeValueTransferMemo
- TxTypeFeeDelegatedValueTransferMemo
- TxTypeFeeDelegatedValueTransferMemoWithRatio
- TxTypeAccountUpdate
- TxTypeFeeDelegatedAccountUpdate
- TxTypeFeeDelegatedAccountUpdateWithRatio
- TxTypeSmartContractDeploy
- TxTypeFeeDelegatedSmartContractDeploy
- TxTypeFeeDelegatedSmartContractDeployWithRatio
- TxTypeSmartContractExecution
- TxTypeFeeDelegatedSmartContractExecution
- TxTypeFeeDelegatedSmartContractExecutionWithRatio
- TxTypeCancel
- TxTypeFeeDelegatedCancel
- TxTypeFeeDelegatedCancelWithRatio
Array [
]
Array [
]
Array [
]
Array [
]
Array [
]
Array [
]
Array [
]
Array [
]
Array [
]
Array [
]
Array [
]
Array [
]
]
Default value: klay_sendTransaction
Method name
Default value: 1
Request ID, Random or Auto incrementation
Default value: 2.0
JSON-RPC Version (2.0)
params
object[]
required
oneOf
The address from which the transaction is sent.
(optional when creating a new contract) The address to which the transaction is directed.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice. The transaction fee is calculated by the multiplication of gas and gasPrice.
(optional) Integer of the value sent with this transaction.
The compiled byte code of a contract to deploy or data (function indicator and parameter values) required to call a contract.
(optional) Integer of a nonce.
The integer indicating TxTypeValueTransfer 8
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice. The transaction fee is calculated by the multiplication of gas and gasPrice.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The integer indicating TxTypeFeeDelegatedValueTransfer 9
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice. The transaction fee is calculated by the multiplication of gas and gasPrice.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The address which pays the transaction fee.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeFeeDelegatedValueTransferWithRatio 10
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The fee payer address of the transaction.
Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. 70% will be paid by the sender. The range of fee ratio is 1 ~ 99, if it is out of range, the transaction will not be accepted.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeValueTransferMemo 16
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice. The transaction fee is calculated by the multiplication of gas and gasPrice.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
The integer indicating TxTypeFeeDelegatedValueTransferMemo 17
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
The fee payer address of the transaction.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeFeeDelegatedValueTransferMemoWithRatio 18
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
The fee payer address of the transaction.
Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. 70% will be paid by the sender. The range of fee ratio is 1 ~ 99, if it is out of range, the transaction will not be accepted.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeAccountUpdate 32
The address from which the transaction is sent.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
The new account key of the from account in RLP encoded format. For more information about the account key, see Account Key.
The integer indicating TxTypeFeeDelegatedAccountUpdate 33
The address from which the transaction is sent.
(optional, default 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
The new account key of the from account in RLP encoded format. For more information about the account key, see Account Key.
The fee payer address of the transaction.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeFeeDelegatedAccountUpdateWithRatio: 34
The address from which the transaction is sent.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
The new account key of the from account in RLP encoded format. For more information about the account key, see Account Key.
The fee payer address of the transaction.
Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. 70% will be paid by the sender. The range of fee ratio is 1 ~ 99, if it is out of range, the transaction will not be accepted.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeSmartContractDeploy: 40
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
true if the address is humanReadable, false if the address is not humanReadable. Currently, the value should be false. Human-readable addresses will be supported later.
The code format of smart contract code. The value 0 indicates EVM.
The integer indicating TxTypeFeeDelegatedSmartContractDeploy: 41
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
true if the address is humanReadable, false if the address is not humanReadable. Currently, the value should be false. Human-readable addresses will be supported later.
The code format of smart contract code. The value 0 indicates EVM.
The fee payer address of the transaction.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeFeeDelegatedSmartContractDeployWithRatio: 42
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
true if the address is humanReadable, false if the address is not humanReadable. Currently, the value should be false. Human-readable addresses will be supported later.
The code format of smart contract code. The value 0 indicates EVM.
The fee payer address of the transaction.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. 70% will be paid by the sender. The range of fee ratio is 1 ~ 99, if it is out of range, the transaction will not be accepted.
The integer indicating TxTypeSmartContractExecution: 48
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
The integer indicating TxTypeFeeDelegatedSmartContractExecution: 49
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
The fee payer address of the transaction.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeFeeDelegatedSmartContractExecutionWithRatio: 50
The address from which the transaction is sent.
The address to which the transaction is directed.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
Integer of the value sent with this transaction.
The data sent along with the transaction.
The fee payer address of the transaction.
Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. 70% will be paid by the sender. The range of fee ratio is 1 ~ 99, if it is out of range, the transaction will not be accepted.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeCancel: 56
The address from which the transaction is sent.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
The integer indicating TxTypeFeeDelegatedCancel: 57
The address from which the transaction is sent.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
The fee payer address of the transaction.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
The integer indicating TxTypeFeeDelegatedCancelWithRatio: 58
The address from which the transaction is sent.
(optional, default: 90000) Integer of the gas provided for the transaction execution. Unused gas will be refunded to the sender. If the specified gas is not enough to execute the transaction, the transaction is reverted.
(optional, default: 25000000000 Peb) Integer of the gasPrice used for each paid gas.
(optional) Integer of a nonce.
The fee payer address of the transaction.
Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. 70% will be paid by the sender. The range of fee ratio is 1 ~ 99, if it is out of range, the transaction will not be accepted.
signatures
object[]
(optional - only for klay_sendTransactionAsFeePayer API) An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
Responses
- 200
Returns the transaction hash.
- application/json
- Schema
- Example (from schema)
Schema
Default value: 2.0
error
object
A Number that indicates the error type that occurred. This MUST be an integer.
| code | message | description | |-----|-----|-------| | -32700 | Parse error | invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. | |-32602 | Invalid params | Invalid method parameter(s). |
A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.
A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
The transaction hash
{
"jsonrpc": "2.0",
"id": 0,
"error": {
"code": -32700,
"message": "Parse error",
"data": "string"
},
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}