Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda