Hi there, I am trying to create a TimeLock smart contract. But my release function always gets reverted by EVM.
I succesfully deployed ERC20 and TimeLock contracts. Transferred tokens from ERC20 tokens creator balanace to ERC20 TimeLock contracts address. The coins are there, time is there, but my transaction always fails when I try to release the tokens. This is my code (all contracts are default code, except for the minting function in ERC20):
async testRelease()
{
console.log('releasing...');
let walletTo = "0x63b095C8fFE3feb0Db3b8Af5704145367Bc65f43";
let walletKey = "[REDACTED]";
let transaction = this.GameCoinVestingContract.methods.release();
const block = await this.web3.eth.getBlock('latest');
const options = {
from : walletTo,
to : transaction._parent._address,
data : transaction.encodeABI(),
gas : block.gasLimit
};
let signed = await this.web3.eth.accounts.signTransaction(options, walletKey);
let tran = await this.web3.eth.sendSignedTransaction(signed.rawTransaction);
//console.log(tran);
console.log('released');
return true;
}
[Nest] 18984 - 07/06/2021, 11:17:06 AM [ExceptionsHandler] Transaction has been reverted by the EVM:
{
"blockHash": "0x1db253d7f4b2c22bae77a39612d391561a50961c9fa6b412a244418542765bcc",
"blockNumber": 19,
"contractAddress": null,
"cumulativeGasUsed": 6394525,
"from": "0x63b095c8ffe3feb0db3b8af5704145367bc65f43",
"gasUsed": 6394525,
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": false,
"to": "0xe55e7a19e971ebaeb75e8b1c1cee8d81d5c55da9",
"transactionHash": "0x3883eb891fbd3527b58fb3d1bdb47276ff70511128df711dfd980ec2df5250b1",
"transactionIndex": 0
}
Also tried:
function release() public virtual {
/* require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time");
uint256 amount = token().balanceOf(address(this));
require(amount > 0, "TokenTimelock: no tokens to release");*/
token().safeTransfer(beneficiary(), 100);
}
INFO [07-06|11:29:17.261] Submitted transaction fullhash=0xc9b52d1685038294f73f43fa6283d9db4b98118de808f678d432510ce1f971b9 recipient=0x9952285127fe0206D6106CD94395d9eE529856Ae
INFO [07-06|11:29:17.261] Commit new mining work number=25 sealhash=c1101f…5c5a45 uncles=0 txs=0 gas=0 fees=0 elapsed=0s
INFO [07-06|11:29:17.261] Sealing paused, waiting for transactions
INFO [07-06|11:29:19.354] Commit new mining work number=25 sealhash=2161ce…0c850a uncles=0 txs=1 gas=6432075 fees=6.432075e-07 elapsed=2.093s
INFO [07-06|11:29:19.355] Successfully sealed new block number=25 sealhash=2161ce…0c850a hash=f73c11…faba59 elapsed=2.000ms
INFO [07-06|11:29:19.363] 🔗 block reached canonical chain number=18 hash=543513…1cadd5
INFO [07-06|11:29:19.366] 🔨 mined potential block number=25 hash=f73c11…faba59
INFO [07-06|11:29:19.364] Sealing paused, waiting for transactions
INFO [07-06|11:29:19.369] Commit new mining work number=26 sealhash=f0d525…39d9ef uncles=0 txs=0 gas=0 fees=0 elapsed=6.001ms
and the transfer coin function which works:
async transferCoin(walletFrom: string, walletKey: string, walletTo: string, amount: number)
{
console.log('Attempting to transfer GameCoin from:' + walletFrom + " to: " + walletTo + " amount: " + amount);
let transfer = this.GameCoinContract.methods.transfer(walletTo, amount);
let encodedABI = transfer.encodeABI();
var gasPrice = await this.web3.eth.getGasPrice();
var gasLimit = 2428000;
var rawTransaction = {
"from": walletFrom,
"to": process.env.GAME_COIN_CONTRACT_ADDRESS,
"gasPrice": gasPrice,
"gasLimit": gasLimit,
"data": encodedABI
};
let signed = await this.web3.eth.accounts.signTransaction(rawTransaction, walletKey);
let tran = await this.web3.eth.sendSignedTransaction(signed.rawTransaction);
console.log('GameCoin transfer complete from:' + walletFrom + " to: " + walletTo + " amount: " + amount);
return true;
}
Any ideas?