I am not a developer but I managed to use openzeppelin to create my first erc20 token for my game project! it’s working wonderfully.
This is a wonderful project! Many thanks for all contributors
I want to use TokenTimelock.sol to create a new contract so that I can send some tokens to it to lock them up for a specific time
here’s my tokenlockup.sol file:
pragma solidity ^0.5.2;
import "openzeppelin-solidity/contracts/token/ERC20/TokenTimelock.sol";
contract lockupMyTokens {
string public constant token = "0xmytokenaddress";
string public constant beneficiary = "0xmyBeneficiaryAddress";
// Test May 28th 8:30 pm GNT
uint256 public constant releaseTime = 1559075400;
}
I deployed it to testnet but I cannot interact with the contract. I think I need to add some function or constructor.
Can anyone help me to add this missing piece?
I looked at all github issues / PRs and couldn’t find an example that I can copy paste and use because I don’t have much dev experience, I couldn’t figure this out and it’s been 2 days now.
Hi @manipulator01
Welcome to the forum. It would be great if you could take a moment and Introduce yourself here! including a bit more about the game you are working on.
A TokenTimelock contract could look as follows:
What you didn’t have was inheriting from TokenTimelock (is TokenTimelock) and calling the TokenTimelock constructor with your desired values.
Once deployed, as you said, you would need to transfer the tokens to the timelock contract.
Note that it’s not necessary to use inheritance to define the constructor arguments.
If you’re using a Truffle/web3.js contract, for example you can pass arguments as TokenTimelock.new(token, beneficiary, release). If you’re using Truffle migrations, I think you can do deployer.deploy(TokenTimelock, token, beneficiary, release).
You deploy a TokenTimelock instance, then you transfer ERC20 tokens to it. All of the ERC20 balance in the timelock will be locked until the specified release date. So the amount is defined by how much you transfer into it.
I set a forward time to lock, send the request. As a result, the success returns, but it happens when you make any withdrawals.
As a result of my tests, it does not work stable
my goal is to generate a new token and integrate tokentimelock
example i want to do and can i do this example
Ex: tokenTimeLock request "withdrawal" : [
{"toAddress":0xaaaaa , "amount": 123455667, "locktime": 1639837380 },
{"toAddress":0xaaaaa , "amount": 347, "locktime": 1639847380 },
{"toAddress":0xaaaaa , "amount": 33242434, "locktime": 1639897380 }
] or
{"toAddress":0xaaaaa , "amount": 123455667, "locktime": 1639837380 }
sample scenario
Wallet1 will send 3 times tokens to Wallet2,
1 st transfer
wallet1 will send 10 tokens to wallet2 and wallet2 will be able to use 10 tokens after 4 days
2 nd transfer
wallet1 will send 7 tokens to wallet2 and wallet2 will be able to use 7 tokens sent at any time
3 rd transfer
wallet1 will send 15 coins to wallet2 and wallet2 will be able to use 15 coins after 9 days
day -> 5.day -> 16.day
7 token unlocked 7 token unlocked 7 token unlocked
10 token locked will open in 4 days 10 token unchecked 10 token unchecked
15 token locked will open in 15 days 15 token locked will open in 11 days 15 token unlocked
total locked token: 25 token total locked token: 15 token total locked token: 0 token
unlocked: 7 unlocked: 17 unlocked: 32
I'm trying to create a "Timelock.sol" like structure using the Openzepplin library and add the MyToken contract. this is the build i'm trying to do, How can I create this structure in a healthy way?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./Timelock";
contract MyToken is ERC20, ERC20Burnable, ERC20Snapshot, Ownable, Pausable, Timelock {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 1000000 * 18 ** decimals());
Timelock(address(0));
}
function snapshot() public onlyOwner {
_snapshot();
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override(ERC20, ERC20Snapshot)
{
super._beforeTokenTransfer(from, to, amount);
}
}
@Amxx Could you clarify a bit about the "one vestingwallet per group" statement? I thought that a VestingWallet only managed one beneficiary (address), so that each person would need his own VestingWallet contract. Is this not the case?