Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Migrate with constructor parameters in Truffle

So basically I'm not quite sure how I can get my parameters from my solidity code and pass them in the deploy function of the deployer for my 2nd migration with Truffle.

This is the constructor of my Solidity code:

constructor(
    IBEP20 _stakeToken,
    IBEP20 _rewardToken,
    uint256 _rewardPerSecond,
    uint256 _startTimestamp,
    uint256 _bonusEndTimestamp
) public {
    stakeToken = _stakeToken;
    rewardToken = _rewardToken;
    rewardPerSecond = _rewardPerSecond;
    startTimestamp = _startTimestamp;
    bonusEndTimestamp = _bonusEndTimestamp;
    // staking pool
    poolInfo.push(PoolInfo({
    lpToken: _stakeToken,
    allocPoint: 1000,
    lastRewardTimestamp: startTimestamp,
    accRewardTokenPerShare: 0
    }));
    totalAllocPoint = 1000;
}

Then this is my javascript migration code:

const tokenstaking = artifacts.require("TokenStaking");
module.exports = function(deployer) {
deployer.deploy(tokenstaking, stakeToken, rewardToken, rewardPerSecond, startTimestamp, 
bonusEndTimestamp);};

Each time I receive the same error for all parameters:

ReferenceError: stakeToken is not defined

How can I reference my parameters? help

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

for parameters you have to pass values. You defined constructor before with parameters. stakeToken, rewardToken, rewardPerSecond, startTimestamp, bonusEndTimestamp. Now you are initalizing the contract, so you have to pass arguments meaning that inital values.

So you have to get values of stakeToken, rewardToken, rewardPerSecond, startTimestamp, bonusEndTimestamp and pass it

deployer.deploy(tokenstaking, 
   "getStakeToken",  // stakeToken 
   "getRewardToken", //rewardToken, 
   "1", // 1 reward per second
   "92389424982",//startTimestamp 
    "99239323232"//bonusEndTimestamp
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda