0

// This is where I get the event information.

const myEvent = myContract.getPastEvents('nftCreated', {fromBlock: 10230636})

// Then the log is something like this:

Promise {                                                                                                            
  <pending>,                                                                                                         
  [Symbol(async_id_symbol)]: 8614,                                                                                   
  [Symbol(trigger_async_id_symbol)]: 2656,                                                                           
  [Symbol(destroyed)]: { destroyed: false }                                                                          
}                                                                                                                    
> [                                                                                                                  
  {                                                                                                                  
    address: '0xF8C3b71BfE0bEEA2cF11F51C4B6370d96bD5c98d',                                                           
    blockHash: '0x239f98cab3616bd0e3218eed61a8c871c96d043f5594662364169680752e6b60',                                 
    blockNumber: 10230636,                                                                                           
    logIndex: 1,                                                                                                     
    removed: false,                                                                                                  
    transactionHash: '0x885a008946923b39b560d465614e119b668b5117e2acf47abe50d41cd286948f',                           
    transactionIndex: 0,                                                                                             
    id: 'log_185ce0cc',                                                                                              
    returnValues: Result {                                                                                           
      '0': 'xxxxxxxxxx',                                                             
      '1': '54366324124',                                                                                            
      '2': '0x3ac1b7722278da916f3996f09357ebdcb17ad8c54a9424b3826f8326c75a0582',                                     
      '3': '1645806587',                                                                                             
      owner: 'xxxxxxxxx',                                                           
      idToken: '54366324124',                                                                                        
      shaCode: '0x3ac1b7722278da916f3996f09357ebdcb17ad8c54a9424b3826f8326c75a0582',                                 
      timestamp: '1645806587'                                                                                        
    },                                                                                                               
    event: 'nftCreated',                                                                                             
    signature: 'xxxxxxxxxxxx',                                 
    raw: {                                                                                                           
      data: '0x000000000000000000000000e3bca80f9dfdc7f72e0e648cdb83c790b20ee45100000000000000000000000000000000000000
00000000000000000ca87c459c3ac1b7722278da916f3996f09357ebdcb17ad8c54a9424b3826f8326c75a0582000000000000000000000000000
00000000000000000000000000000621903fb',                                                                              
      topics: [Array]                                                                                                
    }                                                                                                                
  },                                                                                                                 

1 Answer 1

0

getPastEvents returns promise, you must use like below

try {
  const nftCreatedEvents = await myContract.getPastEvents('nftCreated', {fromBlock: 10230636});

console.log(nftCreatedEvents.map(_ev => _ev.returnValues))
}catch(e) {
   console.log(e)
}

1
  • I just tried it and it worked, thank you very much!!
    – SDX21
    Mar 18, 2022 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.