1

I would like to know if there is a way to obtain the smart contract execution time when you send it to the network through Truffle. Is it possible using the test tool? through an application? I know how to obtain the tx time with web3, but in my case, you need to deploy first an smart contract to the network.

A good example is pet-shop-tutorial. First, truffle deploys the smart contract to the network and then it is possible to obtain different values interacting with the contract using web3. I would like to know how to obtain the time of the first smart contract when is deployed.

1

When you run truffle migrate you can see a list of transactions ids in the console. In order to know when the contract was deployed, you need to know the block where the transaction was added.

You can use the geth console to run js comands by opening a new comand line and typing geth attach rpc:http://localhost:8545

Within the geth console, you have to search the transaction block by typing eth.getTransactionReceipt("0xd285e1a8a91e737fb5ffef588c34275cd1e0ad020afc63d2e8799addf89506d7"); This will show the block number, and then you can run eth.getBlock(1); with the block number from the transactionReceipt detail, to get the timestamp when you contract was deployed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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