For a web application i stored the transaction id of an activity. if the user retry the transaction with a higher gas price in metamask(in case of the transaction take too long, metamask gives this option), is there is any possibility to replace the current transaction id that i stored with new one. how can detect this retry. is there is any web3 method for this?
1 Answer
If you want the same transaction to be carried out but just with a higher gas price, you won't need to replace the transaction ID as that doesn't change.
Calling a function in your front end with web3.js
you would use this piece of code
function functionYouWantToCall() {
web3.eth.getAccounts(function(error, result) {
web3.eth.sendTransaction(
{from:web3.eth.accounts[0],
to: YourContractAddress,
value: "0",
data: "0xTheHashOfTheFuctionYouWantToCall"
}, function(err, result) {
if (!err)
console.log(error);
});
});
}
To find the information you should put in the data field, go to Remix and then on the run tab select details, scroll down to function hashes and select paste in the hash of the function you wish to call with 0x
in front of it. Also make sure to enter your own contracts address in the contract address feild
-
but the retry generates new transaction id, and the old one will always in pending state, after some time this id will delete from etherscan, any solution to get the new id?– AkashCommented Mar 1, 2018 at 7:33
-
Are you doing this with a smart contract that's been uploaded to the blockchain?– JAGCommented Mar 1, 2018 at 7:34
-
-