K
K
Klaytn Docs
Search…
caver.klay.Contract
A caver-js object used to interact with a smart contract.
The caver.klay.Contract object makes it easy to interact with smart contracts on the Klaytn blockchain. When you create a new contract object, you give it the JSON interface of the respective smart contract and caver will auto convert all calls into low level ABI calls over RPC for you.
This allows you to interact with smart contracts as if they were JavaScript objects.

new contract

1
new caver.klay.Contract(jsonInterface [, address] [, options])
Copied!
Creates a new contract instance with all its methods and events defined in its JSON interface object.
Parameters
Name
Type
Description
jsonInterface
Object
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.
The options object contains the following:
Name
Type
Description
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.
Return Value
Type
Description
Object
The contract instance with all its methods and events.
Example
1
var myContract = new caver.klay.Contract([...], '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', {
2
from: '0x1234567890123456789012345678901234567891', // default from address
3
gasPrice: '25000000000' // default gas price in peb, 25 Gpeb in this case
4
});
5
6
var myContract = new caver.klay.Contract([...], 'myContract', {
7
from: '0x1234567890123456789012345678901234567891', // default from address
8
gasPrice: '25000000000' // default gas price in peb, 25 Gpeb in this case
9
});
Copied!

options

1
myContract.options
Copied!
The options object for the contract instance. from, gas and gasPrice are used as fallback values when sending transactions.
Properties
Name
Type
Description
address
String
The address where the contract is deployed. Also see options.address.
jsonInterface
Array
The JSON interface of the contract. Also see options.jsonInterface.
data
String
The byte code of the contract. Used when the contract gets deployed.
from
String
The address from which transactions should be made.
gasPrice
String
The gas price in peb to use for transactions.
gas
Number
The maximum gas provided for a transaction (gas limit).
Example
1
> myContract.options;
2
{
3
address: '0x1234567890123456789012345678901234567891',
4
jsonInterface: [...],
5
from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
6
gasPrice: '10000000000000',
7
gas: 1000000
8
}
9
10
> myContract.options.from = '0x1234567890123456789012345678901234567891'; // default from address
11
> myContract.options.gasPrice = '25000000000000'; // default gas price in peb
12
> myContract.options.gas = 5000000; // provide as fallback always 5M gas
Copied!

options.address

1
myContract.options.address
Copied!
The address used for this contract instance myContract. All transactions generated by caver-js from this contract will contain this address as the "to". The address is stored in lowercase.
Property
Name
Type
Description
address
String | null
The address for this contract or null if it is not yet set.
Example
1
> myContract.options.address;
2
'0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'
3
4
// set a new address
5
> myContract.options.address = '0x1234FFDD...';
Copied!

options.jsonInterface

1
myContract.options.jsonInterface
Copied!
The JSON interface object derived from the ABI of this contract myContract.
Property
Name
Type
Description
jsonInterface
Array
The JSON interface for this contract. Re-setting this will regenerate the methods and events of the contract instance.
Example
1
> myContract.options.jsonInterface;
2
[{
3
"type":"function",
4
"name":"foo",
5
"inputs": [{"name":"a","type":"uint256"}],
6
"outputs": [{"name":"b","type":"address"}]
7
},{
8
"type":"event",
9
"name":"Event"
10
"inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"bytes32","indexed":false}],
11
}]
12
13
// set a new interface
14
> myContract.options.jsonInterface = [...];
Copied!

clone

1
myContract.clone()
Copied!
Clones the current contract instance.
Parameters
None
Return Value
Type
Description
Object
The new cloned contract instance.
Example
1
> var contract1 = new caver.klay.Contract(abi, address, {gasPrice: '12345678', from: fromAddress});
2
> var contract2 = contract1.clone();
3
> contract2.options.address = address2;
4
> (contract1.options.address !== contract2.options.address);
5
true
Copied!

deploy

1
myContract.deploy(options)
Copied!
Deploys the contract to the Klaytn blockchain. After successful deployment, the promise will be resolved with a new contract instance.
Parameters
options: the options object used for deployment:
Name
Type
Description
data
String
The byte code of the contract.
arguments
Array
(optional) The arguments that get passed to the constructor on deployment.
Return Value
Object: The transaction object:
Type
Description
Array
arguments: The arguments passed to the method before. They can be changed.
Function
send: Will deploy the contract. The promise will be resolved with the new contract instance, instead of the receipt.
Function
estimateGas: Will estimate the gas used for the deployment.
Function
encodeABI: Encodes the ABI of the deployment, which is contract data + constructor parameters.
Example
1
> myContract.deploy({
2
data: '0x12345...',
3
arguments: [123, 'My String']
4
})
5
.send({
6
from: '0x1234567890123456789012345678901234567891',
7
gas: 1500000,
8
value: 0,
9
}, function(error, transactionHash) { ... })
10
.on('error', function(error) { ... })
11
.on('transactionHash', function(transactionHash) { ... })
12
.on('receipt', function(receipt) {
13
console.log(receipt.contractAddress) // contains the new contract address
14
})
15
.then(function(newContractInstance) {
16
console.log(newContractInstance.options.address) // instance with the new contract address
17
});
18
19
// When the data is already set as an option to the contract itself
20
> myContract.options.data = '0x12345...';
21
22
> myContract.deploy({
23
arguments: [123, 'My String']
24
})
25
.send({
26
from: '0x1234567890123456789012345678901234567891',
27
gas: 1500000,
28
value: 0,
29
})
30
.then(function(newContractInstance) {
31
console.log(newContractInstance.options.address) // instance with the new contract address
32
});
33
34
// Simply encoding
35
> myContract.deploy({
36
data: '0x12345...',
37
arguments: [123, 'My String']
38
})
39
.encodeABI();
40
'0x12345...0000012345678765432'
41
42
// Gas estimation
43
> myContract.deploy({
44
data: '0x12345...',
45
arguments: [123, 'My String']
46
})
47
.estimateGas(function(err, gas) {
48
console.log(gas);
49
});
Copied!

methods

1
myContract.methods.myMethod([param1 [, param2 [, ...]]])
Copied!
Creates a transaction object for that method, which then can be called, sent, estimated or ABI encoded.
The methods of this smart contract are available through:
  • The name: myContract.methods.myMethod(123)
  • The name with parameters: myContract.methods['myMethod(uint256)'](123)
  • The signature*: myContract.methods['0x58cf5f10'](123)
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 made by 2 different methods. 1. caver.klay.abi.encodeFunctionSignature('funcName(paramType1,paramType2,...)') 2. caver.utils.sha3('funcName(paramType1,paramType2,...)').substr(0, 10)
ex)
1
caver.klay.abi.encodeFunctionSignature('myMethod(uint256)')
2
> 0x58cf5f10
3
4
caver.utils.sha3('myMethod(uint256)').substr(0, 10)
5
> 0x58cf5f10
Copied!
Parameters
Parameters of any method depend on the smart contracts methods, defined in the JSON interface.
Return Value
Object: The transaction object:
Type
Description
Array
arguments: The arguments passed to the method before. They can be changed.
Function
call: Will call the "constant" method and execute its smart contract method in the Klaytn Virtual Machine without sending a transaction (cannot alter the smart contract state).
Function
send: Will send a transaction to the smart contract and execute its method (can alter the smart contract state).
Function
estimateGas: Will estimate the gas used when the method would be executed on the blockchain.
Function
encodeABI: Encodes the ABI for this method. This can be sent using a transaction, calling the method or passing into another smart contract method as argument.
Example
1
// calling a method
2
> myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}, function(error, result) {
3
...
4
});
5
6
// or sending and using a promise
7
> myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
8
.then(function(receipt) {
9
// receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()"
10
});
11
12
// or sending and using the events
13
> myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
14
.on('transactionHash', function(hash) {
15
...
16
})
17
.on('receipt', function(receipt) {
18
...
19
})
20
.on('error', console.error);
Copied!

methods.myMethod.call

1
myContract.methods.myMethod([param1 [, param2 [, ...]]]).call(options [, callback])
Copied!
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.
Parameters
Name
Type
Description
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.
The options object can contain the following:
Name
Type
Description
from
String
(optional) The address the call “transaction” should be made from.
gasPrice
String
(optional) The gas price in peb to use for this call "transaction".
gas
Number
(optional) The maximum gas provided for this call "transaction" (gas limit).
Return Value
Promise returns 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, they are returned as an object with properties and indices.
Example
1
// using the callback
2
> myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}, function(error, result) {
3
...
4
});
5
6
// using the promise
7
> myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
8
.then(function(result) {
9
...
10
});
Copied!
1
// Solidity: MULTI-ARGUMENT RETURN
2
contract MyContract {
3
function myFunction() returns(uint256 myNumber, string myString) {
4
return (23456, "Hello!%");
5
}
6
}
Copied!
1
> var MyContract = new caver.klay.Contract(abi, address);
2
> MyContract.methods.myFunction().call().then(console.log);
3
Result {
4
myNumber: '23456',
5
myString: 'Hello!%',
6
0: '23456', // these are here as fallbacks if the name is not known or given
7
1: 'Hello!%'
8
}
Copied!
1
// Solidity: SINGLE-ARGUMENT RETURN
2
contract MyContract {
3
function myFunction() returns(string myString) {
4
return "Hello!%";
5
}
6
}
Copied!
1
> var MyContract = new caver.klay.Contract(abi, address);
2
> MyContract.methods.myFunction().call().then(console.log);
3
"Hello!%"
Copied!

methods.myMethod.send

1
myContract.methods.myMethod([param1 [, param2 [, ...]]]).send(options [, callback])
Copied!
Will send a transaction to the smart contract and execute its method. Note that this can alter the smart contract state.
Parameters
Name
Type
Description
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.
The options object can contain the following:
Name
Type
Description
from
String
The address from which the transaction should be sent.
gasPrice
String
(optional) The gas price in peb to use for this transaction.
gas
Number
The maximum gas provided for this transaction (gas limit).
value
Number | String | BN | BigNumber
(optional) The value transferred for the transaction in peb.
Return Value
callback will return the 32-byte transaction hash.
PromiEvent: A promise combined event emitter. Will be resolved when the transaction receipt is available, or if this send() is called from a someContract.deploy(), then the promise will be resolved with the new contract instance. Additionally, the following events are available:
Name
Type
Description
transactionHash
String
Is fired right after the transaction is sent and a transaction hash is available.
receipt
Object
Is fired when the transaction receipt is available. Receipts from contracts will have no logs property, but instead an events property with event names as keys and events as properties. See getPastEvents return values for details about the returned event object.
error
Error
Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.
Example
1
// using the callback
2
> myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}, function(error, transactionHash) {
3
...
4
});
5
6
// using the promise
7
> myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
8
.then(function(receipt) {
9
// receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()"
10
});
11
12
13
// using the event emitter
14
> myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
15
.on('transactionHash', function(hash) {
16
...
17
})
18
.on('receipt', function(receipt) {
19
console.log(receipt);
20
})
21
.on('error', console.error); // If there is an out-of-gas error, the second parameter is the receipt.
22
23
// receipt example
24
{
25
"transactionHash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
26
"transactionIndex": 0,
27
"blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
28
"blockNumber": 3,
29
"contractAddress": "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe",
30
"gasUsed": 30234,
31
"events": {
32
"MyEvent": {
33
returnValues: {
34
myIndexedParam: 20,
35
myOtherIndexedParam: '0x123456789...',
36
myNonIndexParam: 'My String'
37
},
38
raw: {
39
data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
40
topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
41
},
42
event: 'MyEvent',
43
signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
44
logIndex: 0,
45
transactionIndex: 0,
46
transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
47
blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
48
blockNumber: 1234,
49
address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
50
},
51
"MyOtherEvent": {
52
...
53
},
54
"MyMultipleEvent":[{...}, {...}] // If there are a multiple of the same events, they will be in an array.
55
}
56
}
Copied!

methods.myMethod.estimateGas

1
myContract.methods.myMethod([param1 [, param2 [, ...]]]).estimateGas(options [, callback])
Copied!
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.
Parameters
Name
Type
Description
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.
The options object can contain the following:
Name
Type
Description
from
String
(optional) The address from which the call "transaction" should be made.
gas
Number
(optional) The maximum gas provided for this call "transaction" (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 transferred for the call "transaction" in peb.
Return Value
Promise returns Number - the used gas for the simulated call/transaction.
Example
1
// using the callback
2
> myContract.methods.myMethod(123).estimateGas({gas: 5000000}, function(error, gasAmount) {
3
if(gasAmount == 5000000)
4
console.log('Method ran out of gas');
5
});
6
7
// using the promise
8
> myContract.methods.myMethod(123).estimateGas({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
9
.then(function(gasAmount) {
10
...
11
})
12
.catch(function(error) {
13
...
14
});
Copied!

methods.myMethod.encodeABI

1
myContract.methods.myMethod([param1 [, param2[, ...]]]).encodeABI()
Copied!
Encodes the ABI for this method. This can be used to send a transaction, call a method, or pass it into another smart contract method as arguments.
Parameters
None
Return Value
Type
Description
String
The encoded ABI byte code to send via a transaction or call.
Example
1
> myContract.methods.myMethod(123).encodeABI();
2
'0x58cf5f1000000000000000000000000000000000000000000000000000000000000007B'
Copied!

once

1
myContract.once(event [, options], callback)
Copied!
Subscribes to an event and unsubscribes immediately after the first event or error. Will only fire for a single event.
Parameters
Name
Type
Description
event
String
The name of the event in the contract, or "allEvents" to get all events.
options
Object
(optional) The options used for deployment. 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 getPastEvents return values for details about the event structure.
The options object can contain the following:
Name
Type
Description
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. If given the filter property and event signature, topic[0] will not be set automatically.
Return Value
undefined
Example
1
> myContract.once('MyEvent', {
2
filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
3
}, function(error, event) { console.log(event); });
4
5
// event output example
6
{
7
returnValues: {
8
myIndexedParam: 20,
9
myOtherIndexedParam: '0x123456789...',
10
myNonIndexParam: 'My String'
11
},
12
raw: {
13
data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
14
topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
15
},
16
event: 'MyEvent',
17
signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
18
logIndex: 0,
19
transactionIndex: 0,
20
transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
21
blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
22
blockNumber: 1234,
23
address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
24
}
Copied!

events

1
myContract.events.MyEvent([options][, callback])
Copied!
Subscribes to an event.
Parameters
Name
Type
Description
options
Object
(optional) The options used for deployment. 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.
The options object can contain the following:
Name
Type
Description
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 on.
topics
Array
(optional) This allows to manually set the topics for the event filter. If given the filter property and event signature, topic[0] will not be set automatically.
Return Value
EventEmitter: The event emitter has the following events:
Name
Type
Description
data
Object
Fires on each incoming event with the event object as argument.
error
Object
Fires when an error in the subscription occurs.
The structure of the returned event Object looks as follows:
Name
Type
Description
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 block 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 max 4 32-byte topics, 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)
Example
1
> myContract.events.MyEvent({
2
filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
3
fromBlock: 0
4
}, function(error, event) { console.log(event); })
5
.on('data', function(event){
6
console.log(event); // same results as the optional callback above
7
})
8
.on('error', console.error);
9
10
// event output example
11
{
12
returnValues: {
13
myIndexedParam: 20,
14
myOtherIndexedParam: '0x123456789...',
15
myNonIndexParam: 'My String'
16
},
17
raw: {
18
data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
19
topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
20
},
21
event: 'MyEvent',
22
signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
23
logIndex: 0,
24
transactionIndex: 0,
25
transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
26
blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
27
blockNumber: 1234,
28
address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
29
id: 'log_41d221bc',
30
}
Copied!

events.allEvents

1
myContract.events.allEvents([options] [, callback])
Copied!
Same as events but receives all events from this smart contract. Optionally, the filter property can filter those events.

getPastEvents

1
myContract.getPastEvents(event [, options] [, callback])
Copied!
Gets past events for this contract.
Parameters
Name
Type
Description
event
String
The name of the event in the contract, or "allEvents" to get all events.
options
Object
(optional) The options used for deployment. 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.
To options object can contain the following:
Name
Type
Description
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 on.
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. If given the filter property and event signature, topic[0] will not be set automatically.
Return Value
Promise returns Array: An array with the past event objects, matching the given event name and filter.
Example
1
> myContract.getPastEvents('MyEvent', {
2
filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
3
fromBlock: 0,
4
toBlock: 'latest'
5
}, function(error, events) { console.log(events); })
6
.then(function(events) {
7
console.log(events) // same results as the optional callback above
8
});
9
10
[{
11
returnValues: {
12
myIndexedParam: 20,
13
myOtherIndexedParam: '0x123456789...',
14
myNonIndexParam: 'My String'
15
},
16
raw: {
17
data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
18
topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
19
},
20
event: 'MyEvent',
21
signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
22
logIndex: 0,
23
transactionIndex: 0,
24
transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
25
blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
26
blockNumber: 1234,
27
address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
28
},{
29
...
30
}]
Copied!
Last modified 1mo ago