Basic type transaction class
LegacyTransaction
caver.transaction.legacyTransaction.create(transactionObject)
LegacyTransaction
represents a legacy transaction. A kaiaaccount can execute a LegacyTransaction
only with AccountKeyLegacy. The transactionObject
can have properties below to create a LegacyTransaction
.
LegacyTransaction
has the properties below as its member variables. Properties marked as optional
refer to properties that can be optionally given in transactionObject
when the user creates LegacyTransaction
.
NOTE: You can create an instance of LegacyTransaction
from RLP-encoded strings. Please refer to the below example.
NOTE: caver.transaction.legacyTransaction.create
is supported since caver-js v1.6.1.
NOTE: As of caver-js v1.8.1-rc.4, creating transactions is only supported using the create
function. If you've been creating transactions using a constructor like new caver.transaction.legacyTransaction({...})
, please change it to caver.transaction.legacyTransaction.create({...})
.
properties
Name | Type | Description |
---|---|---|
gas | string | The maximum amount of transaction fee the transaction is allowed to use. |
value | string | (optional, default: '0x0' ) The amount of KAIA in peb to be transferred. You can use caver.utils.toPeb . |
from | string | (optional) The address of the sender. If omitted, the keyring address used for signing will be set. |
to | string | (optional, default: '0x' ) The account address that will receive the transferred value or smart contact address if a legacy transaction execute smart contract. If a legacy transaction deploys a smart contract, to does not need to be defined. |
input | string | (optional) Data attached to the transaction, used for smart contract deployment/execution. |
signatures | Array | (optional) An array of signatures. A legacy transaction can have only one signature. |
nonce | string | (optional) A value used to uniquely identify a sender’s transaction. If omitted, caver.rpc.klay.getTransactionCount(address, 'pending') will be used to set nonce. |
gasPrice | string | (optional) A multiplier to get how much the sender will pay in tokens. If omitted, caver.rpc.klay.getGasPrice will be used to set gasPrice. |
chainId | string | (optional) The chain id of the kaia network. If omitted, caver.rpc.klay.getChainId will be used to set chainId. |
Example
// Create a legacyTransaction for sending KAIA> caver.transaction.legacyTransaction.create({ to: '0x9957dfd92e4b70f91131c573293343bc5f21f215', value: caver.utils.toPeb(1, 'KLAY'), gas: 25000,})// Create a legacyTransaction to deploy smart contract> caver.transaction.legacyTransaction.create({ input: '0x60806...', gas: 200000,})// Create a legacyTransaction to execute smart contract> caver.transaction.legacyTransaction.create({ to: '0xfe6c9118e56a42cbc77aa3b7ee586455e3dc5b6d', // Smart contact address input: '0xa9059...', gas: 200000,})// Create a legacyTransaction from RLP-encoded string> caver.transaction.legacyTransaction.create('0xf8668204d219830f4240947b65b75d204abed71587c9e519a89277766ee1d00a843132333425a0b2a5a15550ec298dc7dddde3774429ed75f864c82caeb5ee24399649ad731be9a029da1014d16f2011b3307f7bbe1035b6e699a4204fc416c763def6cefd976567')LegacyTransaction { _type: 'TxTypeLegacyTransaction', _from: '0x', _gas: '0xf4240', _nonce: '0x4d2', _gasPrice: '0x19', _signatures: SignatureData { _v: '0x25', _r: '0xb2a5a...', _s: '0x29da1...' }, _to: '0x7b65b75d204abed71587c9e519a89277766ee1d0', _input: '0x31323334', _value: '0xa'}
ValueTransfer
caver.transaction.valueTransfer.create(transactionObject)
ValueTransfer
represents a value transfer transaction. The transactionObject
can have properties below to create a ValueTransfer
transaction.
ValueTransfer
has the properties below as its member variables. Properties marked as optional
refer to properties that can be optionally given in transactionObject
when the user creates ValueTransfer
transaction.
NOTE: You can create an instance of ValueTransfer
from RLP-encoded strings. Please refer to the below example.
NOTE: caver.transaction.valueTransfer.create
is supported since caver-js v1.6.1.
NOTE: As of caver-js v1.8.1-rc.4, creating transactions is only supported using the create
function. If you've been creating transactions using a constructor like new caver.transaction.valueTransfer({...})
, please change it to caver.transaction.valueTransfer.create({...})
.
properties
Name | Type | Description |
---|---|---|
value | string | The amount of KAIA in peb to be transferred. You can use caver.utils.toPeb . |
from | string | The address of the sender. |
to | string | The account address that will receive the transferred value. |
gas | string | The maximum amount of transaction fee the transaction is allowed to use. |
signatures | Array | (optional) An array of signatures. |
nonce | string | (optional) A value used to uniquely identify a sender’s transaction. If omitted, caver.rpc.klay.getTransactionCount(address, 'pending') will be used to set nonce. |
gasPrice | string | (optional) A multiplier to get how much the sender will pay in tokens. If omitted, caver.rpc.klay.getGasPrice will be used to set gasPrice. |
chainId | string | (optional) The chain id of the kaia network. If omitted, caver.rpc.klay.getChainId will be used to set chainId. |
Example
// Create a valueTransfer> caver.transaction.valueTransfer.create({ from: '0x{address in hex}', to: '0x9957dfd92e4b70f91131c573293343bc5f21f215', value: caver.utils.toPeb(1, 'KLAY'), gas: 25000,})// Create a valueTransfer from RLP-encoded string> caver.transaction.valueTransfer.create('0x08f87f3a8505d21dba0083015f90948723590d5d60e35f7ce0db5c09d3938b26ff80ae01947d0104ac150f749d36bb34999bcade9f2c0bd2e6f847f845820feaa03d820b27d0997baf16f98df01c7b2b2e9734ad05b2228c4d403c2facff8397f3a01f4a44eeb8b7f0b0019162d1d6b90c401078e56fcd7495e74f7cfcd37e25f017')ValueTransfer { _type: 'TxTypeValueTransfer', _from: '0x7d0104ac150f749d36bb34999bcade9f2c0bd2e6', _gas: '0x15f90', _nonce: '0x3a', _gasPrice: '0x5d21dba00', _signatures: [ SignatureData { _v: '0x0fea', _r: '0x3d820...', _s: '0x1f4a4...' } ], _to: '0x8723590d5d60e35f7ce0db5c09d3938b26ff80ae', _value: '0x1'}
ValueTransferMemo
caver.transaction.valueTransferMemo.create(transactionObject)
ValueTransferMemo
represents a value transfer memo transaction. The transactionObject
can have properties below to create a ValueTransferMemo
transaction.
ValueTransferMemo
has the properties below as its member variables. Properties marked as optional
refer to properties that can be optionally given in transactionObject
when the user creates ValueTransferMemo
transaction.
NOTE: You can create an instance of ValueTransferMemo
from RLP-encoded strings. Please refer to the below example.
NOTE: caver.transaction.valueTransferMemo.create
is supported since caver-js v1.6.1.
NOTE: As of caver-js v1.8.1-rc.4, creating transactions is only supported using the create
function. If you've been creating transactions using a constructor like new caver.transaction.valueTransferMemo({...})
, please change it to caver.transaction.valueTransferMemo.create({...})
.
properties
Name | Type | Description |
---|---|---|
value | string | The amount of KAIA in peb to be transferred. You can use caver.utils.toPeb . |
from | string | The address of the sender. |
to | string | The account address that will receive the transferred value. |
input | string | Data attached to the transaction. The message should be passed to this property. |
gas | string | The maximum amount of transaction fee the transaction is allowed to use. |
signatures | Array | (optional) An array of signatures. |
nonce | string | (optional) A value used to uniquely identify a sender’s transaction. If omitted, caver.rpc.klay.getTransactionCount(address, 'pending') will be used to set nonce. |
gasPrice | string | (optional) A multiplier to get how much the sender will pay in tokens. If omitted, caver.rpc.klay.getGasPrice will be used to set gasPrice. |
chainId | string | (optional) The chain id of the kaia network. If omitted, caver.rpc.klay.getChainId will be used to set chainId. |
Example
// Create a valueTransferMemo> caver.transaction.valueTransferMemo.create({ from: '0x{address in hex}', to: '0x9957dfd92e4b70f91131c573293343bc5f21f215', value: caver.utils.toPeb(1, 'KLAY'), gas: 25000, input: '0x68656c6c6f',})// Create a valueTransferMemo from RLP-encoded string> caver.transaction.valueTransferMemo.create('0x10f8808204d219830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94a94f5374fce5edbc8e2a8697c15331677e6ebf0b8568656c6c6ff845f84325a07d2b0c89ee8afa502b3186413983bfe9a31c5776f4f820210cffe44a7d568d1ca02b1cbd587c73b0f54969f6b76ef2fd95cea0c1bb79256a75df9da696278509f3')ValueTransferMemo { _type: 'TxTypeValueTransferMemo', _from: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b', _gas: '0xf4240', _nonce: '0x4d2', _gasPrice: '0x19', _signatures: [ SignatureData { _v: '0x25', _r: '0x7d2b0...', _s: '0x2b1cb...' } ], _to: '0x7b65b75d204abed71587c9e519a89277766ee1d0', _value: '0xa', _input: '0x68656c6c6f'}
AccountUpdate
caver.transaction.accountUpdate.create(transactionObject)
AccountUpdate
represents a account update transaction. The transactionObject
can have properties below to create an AccountUpdate
transaction.
AccountUpdate
has the properties below as its member variables. Properties marked as optional
refer to properties that can be optionally given in transactionObject
when the user creates AccountUpdate
transaction.
NOTE: You can create an instance of AccountUpdate
from RLP-encoded strings. Please refer to the below example.
NOTE: caver.transaction.accountUpdate.create
is supported since caver-js v1.6.1.
NOTE: As of caver-js v1.8.1-rc.4, creating transactions is only supported using the create
function. If you've been creating transactions using a constructor like new caver.transaction.accountUpdate({...})
, please change it to caver.transaction.accountUpdate.create({...})
.
properties
Name | Type | Description |
---|---|---|
from | string | The address of the sender. |
account | Account | An Account instance that contains the information needed to update your account. |
gas | string | The maximum amount of transaction fee the transaction is allowed to use. |
signatures | Array | (optional) An array of signatures. |
nonce | string | (optional) A value used to uniquely identify a sender’s transaction. If omitted, caver.rpc.klay.getTransactionCount(address, 'pending') will be used to set nonce. |
gasPrice | string | (optional) A multiplier to get how much the sender will pay in tokens. If omitted, caver.rpc.klay.getGasPrice will be used to set gasPrice. |
chainId | string | (optional) The chain id of the kaia network. If omitted, caver.rpc.klay.getChainId will be used to set chainId. |
For how to create an Account instance for each AccountKey
, refer to Getting Started - Account Update or caver.account.create.
Example
// Create a accountUpdate> caver.transaction.accountUpdate.create({ from: '0x{address in hex}', gas: 50000, account: caver.account.createWithAccountKeyLegacy('0x{address in hex}'),})// Create a accountUpdate from RLP-encoded string> caver.transaction.accountUpdate.create('0x20f88d808505d21dba0083030d4094ffb52bc54635f840013e142ebe7c06c9c91c1625a302a102c93fcbdb2b9dbef8ee5c4748ffdce11f1f5b06d7ba71cc2b7699e38be7698d1ef847f845820fe9a09c2ca281e94567846acbeef724b1a7a5f882d581aff9984755abd92272592b8ea0344fd23d7774ae9c227809bb579387dfcd69e74ae2fe3a788617f54a4001e5ab')AccountUpdate { _type: 'TxTypeAccountUpdate', _from: '0xffb52bc54635f840013e142ebe7c06c9c91c1625', _gas: '0x30d40', _nonce: '0x0', _gasPrice: '0x5d21dba00', _signatures: [ SignatureData { _v: '0x0fe9', _r: '0x9c2ca...', _s: '0x344fd...' } ], _account: Account { _address: '0xffb52bc54635f840013e142ebe7c06c9c91c1625', _accountKey: AccountKeyPublic { _publicKey: '0x02c93...' } }}