Openzeppelin-contracts: TokenVesting release method failing

Created on 31 Jul 2020  路  3Comments  路  Source: OpenZeppelin/openzeppelin-contracts

I am trying to release tokens from a TokenVesting contract. This transaction fails with a "'gas required exceeds allowance (10000000) or always failing transaction'" error.

馃捇 Environment

drafts/TokenVesting.sol contract from @openzeppelin/contracts@^3.0.1

Using buidler to deploy the contract like so, after which I send the address ERC20 tokens.

import { ethers } from "@nomiclabs/buidler";
import TokenVesting from "@openzeppelin/contracts/build/contracts/TokenVesting.json";

async function main() {
  const [deployer] = await ethers.getSigners();

  const beneficiary = "0x01727f13cf4173437E86eC7E7b780502DD5eBF8D";
  const start = Date.now() + 120;
  const cliffDuration = 0;
  const durationSeconds = 720;
  const revocable = true;

  console.log(
    "Deploying contracts with the account:",
    await deployer.getAddress()
  );

  const Vesting = new ethers.ContractFactory(
    TokenVesting.abi,
    TokenVesting.bytecode,
    deployer
  );
  const tokenVesting = await Vesting.deploy(
    beneficiary,
    start,
    cliffDuration,
    durationSeconds,
    revocable
  );

  await tokenVesting.deployed();
  console.log("TokenVesting address:", tokenVesting.address);
}

main()
  .then(() => process.exit(0))
  .catch(error => {
    console.error(error);
    process.exit(1);
  });

馃摑 Details

Calling release fails.

馃敘 Code to reproduce bug

import { ethers } from "@nomiclabs/buidler";
import TokenVesting from "@openzeppelin/contracts/build/contracts/TokenVesting.json";

async function main() {
  const [deployer] = await ethers.getSigners();

  const tokenVestingAddress = "0x072efE1C0161AB2eFe2c4A803931D1E42BcA62ff";
  const tokenAddress = "0x7d50101bbfa12f4a1b4e6de0dd58ad36de150d55";

  console.log("Calling release on TokenVesting:", tokenVestingAddress);
  const tokenVesting = await ethers.getContractAt(
    TokenVesting.abi,
    tokenVestingAddress,
    deployer
  );

  const response = await tokenVesting.release(tokenAddress);
  console.log(response);

  const receipt = await response.wait();
  console.log(receipt);
}

main()
  .then(() => process.exit(0))
  .catch(error => {
    console.error(error);
    process.exit(1);
  });

Most helpful comment

Im not seeing where you actually transfer the Tokens to the TokenVesting contract. Does the Vesting contract hold any tokens before executing release? Tokens to be vested need to be transferred to the TokenVesting contract.

All 3 comments

Acknowledge this is a draft but I think I'm missing something here..

Im not seeing where you actually transfer the Tokens to the TokenVesting contract. Does the Vesting contract hold any tokens before executing release? Tokens to be vested need to be transferred to the TokenVesting contract.

Thanks @julianmrodri yes I was transferring the tokens (should have made that more clear)

but I realized my error was in using Date.now which gives ms instead of seconds. So closing this!

Was this page helpful?
0 / 5 - 0 ratings