The caver.contract object makes it easy to interact with smart contracts on the Klaytn blockchain platform. When you create a new contract object, you have to provide the JSON interface for that smart contract and caver-js will automatically convert all calls with the contract object in javascript into low-level ABI calls over RPC for you.
This allows you to interact with smart contracts as if they were JavaScript objects.
Creates a new contract instance with all its methods and events defined in its JSON interface object. This function works the same as new caver.contract.
NOTEcaver.contract.create is supported since caver-js v1.6.1.
Creates a new contract instance with all its methods and events defined in its JSON interface object.
Parameters
The options object contains the following:
Return Value
Example
constmyContract=newcaver.contract([...],'0x{address in hex}', { gasPrice:'25000000000' })
myContract.options
myContract.options
The options object for the contract instance. from, gas, gasPrice, feePayer and feeRatio are used as fallback values when sending transactions.
Properties
NOTEfeeDelegation, feePayer and feeRatio are supported since caver-js v1.6.1.
Example
>myContract.options{ address: [Getter/Setter], jsonInterface: [Getter/Setter], from: [Getter/Setter], feePayer: [Getter/Setter], feeDelegation: [Getter/Setter], feeRatio: [Getter/Setter], gasPrice: [Getter/Setter], gas: [Getter/Setter], data: [Getter/Setter]}>myContract.options.from ='0x1234567890123456789012345678901234567891'// default from address>myContract.options.gasPrice ='25000000000000'// default gas price in peb>myContract.options.gas =5000000// provide as fallback always 5M gas>myContract.options.feeDelegation =true// use fee delegation transaction>myContract.options.feePayer ='0x1234567890123456789012345678901234567891'// default fee payer address>myContract.options.feeRatio =20// default fee ratio when send partial fee delegation transaction
myContract.options.address
myContract.options.address
The address used for this contract instance myContract. All transactions generated by caver-js from this contract will contain this address as the to of the transaction.
Property
Example
>myContract.options.address'0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'// set a contract address>myContract.options.address ='0x1234FFDD...'
myContract.options.jsonInterface
myContract.options.jsonInterface
The JSON interface object derived from the ABI of this contract myContract.
Deploys the contract to the Klaytn network. After a successful deployment, the promise will be resolved with a new contract instance. Unlike the usability of the existing myContract.deploy function, this function sends a transaction directly to the Klaytn network. You don't need to call send() with the returned object.
NOTEcaver.wallet must contains keyring instances corresponding to from and feePayer in options or myContract.options to make signatures.
NOTEmyContract.deploy is supported since caver-js v1.6.1.
Parameters
Return Value
Promise returning PromiEvent: The promise will be resolved with the new contract instance.
For PromiEvent, the following events are available:
transactionHash: it is fired right after the transaction is sent and a transaction hash is available. Its type is string.
error: It is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt. Its type is Error.
Example
// Deploy a smart contract without constructor arguments>myContract.deploy({ from:'0x{address in hex}', gas:1500000, },'0x{byte code}').on('error',function(error) { ... }).on('transactionHash',function(transactionHash) { ... }).on('receipt',function(receipt) {console.log(receipt.contractAddress) // contains the new contract address }).then(function(newContractInstance) {console.log(newContractInstance.options.address) // instance with the new contract address })// Deploy a smart contract with constructor arguments>myContract.deploy({ from:'0x{address in hex}', gas:1500000, },'0x{byte code}','keyString',...).on('error',function(error) { ... }).on('transactionHash',function(transactionHash) { ... }).on('receipt',function(receipt) {console.log(receipt.contractAddress) }).then(function(newContractInstance) {console.log(newContractInstance.options.address) })// Deploy a smart contract with fee delegation transaction (TxTypeFeeDelegatedSmartContractDeploy)>myContract.deploy({ from:'0x{address in hex}', feeDelegation:true, feePayer:'0x{address in hex}', gas:1500000, },'0x{byte code}').on('error',function(error) { ... }).on('transactionHash',function(transactionHash) { ... }).on('receipt',function(receipt) {console.log(receipt.contractAddress) }).then(function(newContractInstance) {console.log(newContractInstance.options.address) })// Deploy a smart contract with partial fee delegation transaction (TxTypeFeeDelegatedSmartContractDeployWithRatio)>myContract.deploy({ from:'0x{address in hex}', feeDelegation:true, feePayer:'0x{address in hex}', feeRatio:30, gas:1500000, },'0x{byte code}').on('error',function(error) { ... }).on('transactionHash',function(transactionHash) { ... }).on('receipt',function(receipt) {console.log(receipt.contractAddress) }).then(function(newContractInstance) {console.log(newContractInstance.options.address) })
myContract.deploy
myContract.deploy(options)
Returns the object used when deploying the smart contract to the Klaytn. You can send the smart contract deploy transaction via calling myContract.deploy({ data, arguments }).send(options). After a successful deployment, the promise will be resolved with a new contract instance.
Parameters
The options object can contain the following:
Return Value
The object contains the following:
NOTEmyContract.deploy({ data, arguments }).sign(options) and myContract.deploy({ data, arguments }).signAsFeePayer(options) are supported since caver-js v1.6.1.
Example
>myContract.deploy({ data:'0x12345...', arguments: [123,'My string'] }).send({ from:'0x1234567890123456789012345678901234567891', gas:1500000, value:0, },function(error, transactionHash) { ... }).on('error',function(error) { ... }).on('transactionHash',function(transactionHash) { ... }).on('receipt',function(receipt) {console.log(receipt.contractAddress) // contains the new contract address }).then(function(newContractInstance) {console.log(newContractInstance.options.address) // instance with the new contract address })// When the data is already set as an option to the contract itself>myContract.options.data ='0x12345...'>myContract.deploy({ arguments: [123,'My string'] }).send({ from:'0x1234567890123456789012345678901234567891', gas:1500000, value:0, }).then(function(newContractInstance) {console.log(newContractInstance.options.address) // instance with the new contract address })// Simply encoding>myContract.deploy({ data:'0x12345...', arguments: [123,'My string'] }).encodeABI()'0x12345...0000012345678765432'// Gas estimation>myContract.deploy({ data:'0x12345...', arguments: [123,'My string'] }).estimateGas(function(err, gas) {console.log(gas) })
Submits a transaction to execute the function of the smart contract. This can alter the smart contract state.
The transaction type used for this function depends on the options or the value defined in myContract.options. If you want to use a fee-delegated transaction through myContract.send, feeDelegation and feePayer should be set properly.
Signs a smart contract transaction as a sender to deploy the smart contract or execute the function of the smart contract.
If a smart contract is deployed, 'constructor' can be entered in the methodName, such as myContract.sign({ from, ... }, 'constructor', byteCode, ...).
The transaction type used for this function depends on the options or the value defined in myContract.options. If you want to use a fee-delegated transaction through myContract.sign, feeDelegation should be defined as true.
Signs a smart contract transaction as a fee payer to deploy the smart contract or execute the function of the smart contract.
If a smart contract is deployed, 'constructor' can be entered in the methodName, such as myContract.signAsFeePayer({ from, feeDelegation: true, feePayer, ... }, 'constructor', byteCode, ...).
The transaction type used for this function depends on the options or the value defined in myContract.options. The signAsFeePayer is a function that signs as a transaction fee payer, so feeDelegation field must be defined as true. Also, the address of the fee payer must be defined in the feePayer field.
feeDelegation is not defined : Throws an error.
feeDelegation is defined, but feePayer is not defined : Throws an error.
Will call a constant method and execute its smart contract method in the Klaytn Virtual Machine without sending any transaction. Note that calling cannot alter the smart contract state.
NOTEmyContract.call is supported since caver-js v1.6.1.
Parameters
Return Value
Promise returning Mixed - The return value(s) of the smart contract method. If it returns a single value, it is returned as it is. If it has multiple return values, it returns an object with properties and indices.
Example
>myContract.call('methodName').then(console.log)Jasmine>myContract.call({ from:'0x{address in hex}' },'methodName',123).then(console.log)Test Result
myContract.decodeFunctionCall
myContract.decodeFunctionCall(functionCall)
Decodes a function call and returns parameters.
NOTEmyContract.decodeFunctionCall is supported since caver-js v1.6.3.
This allows calling functions with the same name but different parameters from the JavaScript contract object.
cf) *function signature (function selector)
The first four bytes of the call data for a function call specifies the function to be called.
It is the first (left, high-order in big-endian) four bytes of the Keccak-256 (SHA-3) hash of the signature of the function.
The function signature can be given via 2 different methods.
1. caver.abi.encodefunctionSignature('funcName(paramType1,paramType2,...)')2. caver.utils.sha3('funcName(paramType1,paramType2,...)').substr(0, 10)
Parameters of any method that belongs to this smart contract, defined in the JSON interface.
Return Value
Promise returning object - An object in which arguments and functions for contract execution are defined.:
NOTEsign and signAsFeePayer are supported since caver-js v1.6.1.
Example
// Calling a method>myContract.methods.methodName(123).call({ ... },function(error, result) { ... })>myContract.methods.methodName(123).call({ ... }).then((result) => { ... })// Sending basic transaction and using the promise>myContract.methods.methodName(123).send({ from:'0x{address in hex}',... }).then(function(receipt) {// receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()" })// Sending basic transaction and using the eventEmitter>myContract.methods.methodName(123).send({ from:'0x{address in hex}',... }).on('transactionHash',function(hash) {... }).on('receipt',function(receipt) {... }).on('error',console.error)// Sending fee delegation transaction and using the promise>myContract.methods.methodName(123).send({ from:'0x{address in hex}', feePayer:'0x{fee-payer address}', feeDelegation:true,f... }).then(function(receipt) {// receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()" })// Sending partial fee delegation transaction and using the promise>myContract.methods.methodName(123).send({ from:'0x{address in hex}', feePayer:'0x{fee-payer address}', feeDelegation:true, feeRatio:30,... }).then(function(receipt) {// receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()" })// sign the basic transaction>myContract.methods.methodName(123).sign({ from:'0x{address in hex}', feeDelegation:true,... }).then(function(signedTx) { ... })// sign the fee delegation transaction>myContract.methods.methodName(123).sign({ from:'0x{address in hex}', feeDelegation:true,... }).then(function(signedTx) { ... })// sign the partial fee delegation transaction>myContract.methods.methodName(123).sign({ from:'0x{address in hex}', feeDelegation:true, feeRatio:30,... }).then(function(signedTx) { ... })// sign the fee delegation transaction as a fee payer>myContract.methods.methodName(123).signAsFeePayer({ from:'0x{address in hex}', feePayer:'0x{fee-payer address}', feeDelegation:true,... }).then(function(signedTx) { ... })// sign the partial fee delegation transaction as a fee payer>myContract.methods.methodName(123).signAsFeePayer({ from:'0x{address in hex}', feePayer:'0x{fee-payer address}', feeDelegation:true, feeRatio:30,... }).then(function(signedTx) { ... })
Will call a constant method and execute its smart contract method in the Klaytn Virtual Machine without sending any transaction. Note that calling cannot alter the smart contract state. It is recommended to use myContract.call provided as a short-cut function.
Parameters
The options object can contain the following:
Return Value
Promise returning Mixed - The return value(s) of the smart contract method. If it returns a single value, it is returned as it is. If it has multiple return values, it returns an object with properties and indices.
Example
// using the promise>myContract.methods.methodName(123).call({from:'0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}).then(function(result) {... })
Will send a transaction to deploy the smart contract or execute the function of the smart contract. This can alter the smart contract state. It is recommended to use myContract.send provided as a short-cut function.
If a smart contract is deployed, 'constructor' can be entered in the methodName, such as myContract.methods.constructor or myContract.methods['constructor'], but it is recommended to use the myContract.deploy function.
The transaction type used for this function depends on the options or the value defined in myContract.options. If you want to use a fee-delegated transaction through methods.methodName.send, feeDelegation and feePayer should be set properly.
error: It is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt. Its type is Error.
Example
// using the promise>myContract.methods.methodName(123).send({from:'0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}).then(function(receipt) {// receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()" })// using the event emitter>myContract.methods.methodName(123).send({from:'0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}).on('transactionHash',function(hash) {... }).on('receipt',function(receipt) {console.log(receipt) }).on('error',console.error) // If there is an out-of-gas error, the second parameter is the receipt.// receipt example{"transactionHash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b","transactionIndex": 0,"blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46","blocknumber": 3,"contractAddress": "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe","gasUsed": 30234,"events": {"eventName": { returnValues: { myIndexedParam:20, myOtherIndexedParam:'0x123456789...', myNonIndexParam:'My string' }, raw: { data:'0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385', topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
}, event:'eventName', signature:'0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', logIndex:0, transactionIndex:0, transactionHash:'0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385', blockHash:'0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', blocknumber:1234, address:'0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe' },"MyOtherEvent": {... },"MyMultipleEvent":[{...}, {...}] // If there are multiples of the same events, they will be in an array. }}// Deploy the contract> myContract.methods.constructor('0x{byte code}', 123).send({ from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', gas: 1000000 })
> myContract.methods['constructor']('0x{byte code}', 123).send({ from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', gas: 1000000 })
Signs a smart contract transaction as a sender to deploy the smart contract or execute the function of the smart contract. It is recommended to use myContract.sign provided as a short-cut function.
If a smart contract is deployed, 'constructor' can be entered in the methodName, such as myContract.methods.constructor or myContract.methods['constructor'].
The transaction type used for this function depends on the options or the value defined in myContract.options. If you want to use a fee-delegated transaction through methods.methodName.sign, feeDelegation should be defined as true.
Signs a smart contract transaction as a fee payer to deploy the smart contract or execute the function of the smart contract. It is recommended to use myContract.signAsFeePayer provided as a short-cut function.
If a smart contract is deployed, 'constructor' can be entered in the methodName, such as myContract.methods.constructor or myContract.methods['constructor'].
The transaction type used for this function depends on the options or the value defined in myContract.options. The signAsFeePayer is a function that signs as a transaction fee payer, so feeDelegation field must be defined as true. Also, the address of the fee payer must be defined in the feePayer field.
feeDelegation is not defined : Throws an error.
feeDelegation is defined, but feePayer is not defined : Throws an error.
Will estimate the gas that a method execution will take when executed in the Klaytn Virtual Machine. The estimation can differ from the actual gas used when later sending a transaction, as the state of the smart contract can be different at that time.
The JSON interface for the contract to instantiate
address
string
(optional) The address of the smart contract to call. Can be added later using myContract.options.address = '0x1234..'
options
object
(optional) The options of the contract. See the table below for the details.
from
string
(optional) The address from which transactions should be made.
gasPrice
string
(optional) The gas price in peb to use for transactions.
gas
number
(optional) The maximum gas provided for a transaction (gas limit).
data
string
(optional) The byte code of the contract. Used when the contract gets deployed.
feeDelegation
boolean
(optional) Whether to use fee delegation transaction.
feePayer
string
(optional) The address of the fee payer paying the transaction fee. When feeDelegation is true, the value is set to the feePayer field in the transaction.
feeRatio
string
(optional) The ratio of the transaction fee the fee payer will be burdened with. If feeDelegation is true and feeRatio is set to a valid value, a partial fee delegation transaction is used. The valid range of this is between 1 and 99. The ratio of 0, or 100 and above are not allowed.
object
The contract instance with all its methods and events.
address
string
The address where the contract is deployed.
jsonInterface
Array
The JSON interface of the contract.
from
string
The default address from which the contract deployment/execution transaction is sent. If the from address is not defined when creating the transaction, this myContract.options.from is always used to create the transaction.
gasPrice
string
The gas price in peb to use for transactions.
gas
number
The maximum gas provided for a transaction (gas limit).
data
string
The byte code of the contract. Used when the contract gets deployed.
feeDelegation
boolean
(optional) Whether to use fee delegation transaction.
feePayer
string
(optional) The address of the fee payer paying the transaction fee. When feeDelegation is true, the value is set to the feePayer field in the transaction.
feeRatio
string
(optional) The ratio of the transaction fee the fee payer will be burdened with. If feeDelegation is true and feeRatio is set to a valid value, a partial fee delegation transaction is used. The valid range of this is between 1 and 99. The ratio of 0, or 100 and above are not allowed.
address
string | null
The address for this contract or null if it is not yet set.
jsonInterface
Array
The JSON interface for this contract. Re-setting this will regenerate the methods and events of the contract instance.
contractAddress
String
(optional) The address of the new contract. If omitted, it will be set to the address in the original instance (e.g., myContract.options.address).
(optional) The parameters that get passed to the constructor on deployment.
PromiEvent
A promise combined event emitter. It will be resolved when the transaction receipt is available. If send() is called from a myContract.deploy(), then the promise will be resolved with the new contract instance.
options
object
The options object used for deployment. See the below table to find the description.
data
string
The byte code of the contract.
arguments
Array
(optional) The arguments that get passed to the constructor on deployment.
object
An object in which arguments and functions for contract distribution are defined. See the below table to find the description.
The function that encodes the ABI of the deployment, which is contract data + constructor parameters. The execution of this function does not deploy the contract.
The method name of the contract function to execute.
parameters
Mixed
(optional) The parameters that get passed to the smart contract function.
PromiEvent
A promise combined event emitter. It will be resolved when the transaction receipt is available. The promise will be resolved with the new contract instance.
The method name of the contract function to execute. If you want to sign a transaction for deploying the smart contract, use 'constructor' string instead of method name.
parameters
Mixed
(optional) The parameters that get passed to the smart contract function. If you want to sign a smart contract deploy transaction, pass the byteCode and constructor parameters.
The method name of the contract function to execute. If you want to sign a transaction for deploying the smart contract, use 'constructor' string instead of method name.
parameters
Mixed
(optional) The parameters that get passed to the smart contract function. If you want to sign a smart contract deploy transaction, pass the byteCode and constructor parameters.
options
object
(optional) The options used for calling. See the table in methods.methodName.call for the details.
methodName
string
The method name of the contract function to call.
parameters
Mixed
(optional) The parameters that get passed to the smart contract function.
functionCall
string
The encoded function call string.
object
An object which includes plain params. You can use result[0] as it is provided to be accessed like an array in the order of the parameters.
The function that will call and execute a constant method in its smart contract on Klaytn Virtual Machine without sending a transaction (cannot alter the smart contract state).
The function that encodes the ABI for this method. This can be sent using a transaction, calling the method, or passing into another smart contract method as its argument.
options
object
(optional) The options used for calling. See the table below for the details.
callback
function
(optional) This callback will be fired with the result of the smart contract method execution as the second argument, or with an error object as the first argument.
from
string
(optional) The address which calling contract methods should be made from.
gasPrice
string
(optional) The gas price in peb to use for this call.
gas
number
(optional) The maximum gas provided for this call (gas limit).
options
object
The options used for sending. See the table below for the details.
callback
function
(optional) This callback will be fired first with the "transactionHash", or with an error object as the first argument.
from
string
The address from which the transaction should be sent. If omitted, myContract.options.from will be used.
gas
number
The maximum gas provided for this transaction (gas limit).
gasPrice
string
(optional) The gas price in peb to use for this transaction.
value
number | string | BN | Bignumber
(optional) The value in peb to be transferred to the address of the smart contract by this transaction.
feeDelegation
boolean
(optional, default false) Whether to use fee delegation transaction. If omitted, myContract.options.feeDelegation will be used.
feePayer
string
(optional) The address of the fee payer paying the transaction fee. When feeDelegation is true, the value is set to the feePayer field in the transaction. If omitted, myContract.options.feePayer will be used.
feeRatio
string
(optional) The ratio of the transaction fee the fee payer will be burdened with. If feeDelegation is true and feeRatio is set to a valid value, a partial fee delegation transaction is used. The valid range of this is between 1 and 99. The ratio of 0, or 100 and above are not allowed. If omitted, myContract.options.feeRatio will be used.
PromiEvent
A promise combined event emitter. It will be resolved when the transaction receipt is available. The promise will be resolved with the new contract instance.
options
object
The options used for creating a transaction. See the parameter table in methods.methodName.send for the details.
options
object
The options used for creating a transaction. See the parameter table in methods.methodName.send for the details.
options
object
(optional) The options used for calling. See the table below for the details.
callback
function
(optional) This callback will be fired with the result of the gas estimation as the second argument, or with an error object as the first argument.
from
string
(optional) The address from which calling the contract method should be made.
gas
number
(optional) The maximum gas provided for this call (gas limit). Setting a specific value helps to detect out of gas errors. If all gas is used, it will return the same number.
value
number | string | BN | Bignumber
(optional) The value in peb that would be transferred to the address of the smart contract if the transaction for executing this contract function was sent to Klaytn.
number
The used gas for the simulated call/transaction.
string
The encoded ABI byte code to send via a transaction or call.
event
string
The name of the event in the contract, or allEvents to get all events.
options
object
(optional) The options used for subscription. See the table below for the details.
callback
function
This callback will be fired for the first event as the second argument, or an error as the first argument. See myContract.getPastEvents for details about the event structure.
filter
object
(optional) Lets you filter events by indexed parameters, e.g., {filter: {mynumber: [12,13]}} means all events where "mynumber" is 12 or 13.
topics
Array
(optional) This allows you to manually set the topics for the event filter. Given the filter property and event signature, topic[0] would not be set automatically.
event
string
The name of the event in the contract, or allEvents to get all events.
options
object
(optional) The options used for subscription. See the table below for the details.
callback
function
This callback will be fired for the first event as the second argument, or an error as the first argument. See myContract.getPastEvents for details about the event structure.
filter
object
(optional) Lets you filter events by indexed parameters, e.g., {filter: {mynumber: [12,13]}} means all events where "mynumber" is 12 or 13.
topics
Array
(optional) This allows you to manually set the topics for the event filter. Given the filter property and event signature, topic[0] would not be set automatically.
options
object
(optional) The options used for subscription. See the table below for the details.
callback
function
(optional) This callback will be fired for each event as the second argument, or an error as the first argument.
filter
object
(optional) Lets you filter events by indexed parameters, e.g., {filter: {mynumber: [12,13]}} means all events where "mynumber" is 12 or 13.
fromBlock
number
(optional) The block number from which to get events.
topics
Array
(optional) This allows you to manually set the topics for the event filter. Given the filter property and event signature, topic[0] would not be set automatically.
data
object
Fires on each incoming event with the event object as an argument.
connected
string
Fires once after the subscription successfully connected. It returns the subscription ID.
error
object
Fires when an error in the subscription occurs.
event
string
The event name.
signature
string | null
The event signature, null if it is an anonymous event.
address
string
Address which from this event originated.
returnValues
object
The return values coming from the event, e.g., {myVar: 1, myVar2: '0x234...'}.
logIndex
number
Integer of the event index position in the block.
transactionIndex
number
Integer of the transaction's index position where the event was created.
transactionHash
32-byte string
Hash of the transaction this event was created in. null when it is still pending.
blockHash
32-byte string
Hash of the block this event was created in. null when it is still pending.
blocknumber
number
The block number this log was created in. null when still pending.
raw.data
string
The data containing non-indexed log parameter.
raw.topics
Array
An array with a maximum of four 32-byte topics, and topic 1-3 contains indexed parameters of the event.
id
string
A log identifier. It is made through concatenating "log_" string with keccak256(blockHash + transactionHash + logIndex).substr(0, 8)
event
string
The name of the event in the contract, or "allEvents" to get all events.
options
object
(optional) The options used for subscription. See the table below for the details.
callback
function
(optional) This callback will be fired with an array of event logs as the second argument, or an error as the first argument.
filter
object
(optional) Lets you filter events by indexed parameters, e.g., {filter: {mynumber: [12,13]}} means all events where "mynumber" is 12 or 13.
fromBlock
number
(optional) The block number from which to get events.
toBlock
number
(optional) The block number to get events up to (defaults to "latest").
topics
Array
(optional) This allows manually setting the topics for the event filter. Given the filter property and event signature, topic[0] would not be set automatically.
event
string
The event name.
signature
string | null
The event signature, null if it’s an anonymous event.
address
string
Address this event originated from.
returnValues
object
The return values coming from the event, e.g. {myVar: 1, myVar2: '0x234...'}.
logIndex
number
The event index position in the block.
transactionIndex
number
The transaction’s index position the event was created in.
transactionHash
string
The hash of the transaction this event was created in.
blockHash
string
The hash of the block this event was created in. null when it’s still pending.
blockNumber
number
The block number this log was created in. null when still pending.
raw
object
An object defines data and topic. raw.data containing non-indexed log parameter. raw.topic is an array with a maximum of four 32 Byte topics, and topic 1-3 contains indexed parameters of the event.