The ITX demo on github contains an error in call.js source code. The following is defined twice:
const relayTransactionHash
Which results in the error: SyntaxError: Identifier ‘relayTransactionHash’ has already been declared
These are the locations where relayTransactionHash is defined:
// Encoded data payload representing the contract method call
data: iface.encodeFunctionData('echo', [`Hello world at ${Date.now()}!`]),
// An upper limit on the gas we're willing to spend
gas: '100000',
};
// Sign a relay request using the signer's private key
// Final signature of the form keccak256("\x19Ethereum Signed Message:\n" + len((to + data + gas + chainId)) + (to + data + gas + chainId)))
// Where (to + data + gas + chainId) represents the RLP encoded concatenation of these fields.
// ITX will check the from address of this signature and deduct balance according to the gas used by the transaction
const relayTransactionHash = ethers.utils.keccak256(
ethers.utils.defaultAbiCoder.encode(
['address', 'bytes', 'uint', 'uint'],
[tx.to, tx.data, tx.gas, 4] // Rinkeby chainId is 4
)
);
const signature = await signer.signMessage(ethers.utils.arrayify(relayTransactionHash));
// Relay the transaction through ITX
const relayTransactionHash = await itx.send('relay_sendTransaction', [tx, signature]);
console.log(`ITX relay transaction hash: ${relayTransactionHash}`);
// ITX will check the from address of this signature and deduct balance according to the gas used by the transaction
const relayTransactionHash = ethers.utils.keccak256(
ethers.utils.defaultAbiCoder.encode(
['address', 'bytes', 'uint', 'uint'],
[tx.to, tx.data, tx.gas, 4] // Rinkeby chainId is 4
)
);
const signature = await signer.signMessage(ethers.utils.arrayify(relayTransactionHash));
// Relay the transaction through ITX
const relayTransactionHash = await itx.send('relay_sendTransaction', [tx, signature]);
console.log(`ITX relay transaction hash: ${relayTransactionHash}`);
// Waiting for the corresponding Ethereum transaction to be mined
// We poll the relay_getTransactionStatus method for status updates
// ITX bumps the gas price of your transaction until it's mined,
// causing a new transaction hash to be created each time it happens.
// relay_getTransactionStatus returns a list of these transaction hashes
// which can then be used to poll Infura for their transaction receipts
console.log('Waiting to be mined...');
while (true) {
Lily
January 5, 2021, 2:10pm
2
Thank you so much for watching out @gpersoon . There is a pull request for this, and hopefully, the team will review this and have it merged soon. You can follow the pr here https://github.com/INFURA/demo-eth-tx/pull/3
We merged the PR and this should fix the problem, thank you @gpersoon for flagging this up!