0

I created 2 smart contracts.

contract A is ERC20 token and B is a contract that accepts ERC20 A as payment method. When deploying, contract A got deployed but when I passed its proxy address to the initialize function in contract B for deployment it shows this error: TypeError: Cannot create property 'kind' on string '0x814bd9012bD1e51b86890343b9731501875502e8'

what could be the problem?

hardhat deploy script

  const token = await ethers.getContractFactory("Token");
  console.log("Deploying token...");
  const tokeninit= await upgrades.deployProxy(token , {
    initializer: "initialize",
    });

  await tokeninit.deployed();
  const tokenaddr = tokeninit.address;

  console.log("token deployed at :", tokenaddr );
  const SmartB= await ethers.getContractFactory("SmartB");
  const SmartBInit= await upgrades.deployProxy(SmartB,tokenaddr, {
    initializer: "initialize",
    });

Smart contract B shorten code:

contract SamrtB is Initializable, UUPSUpgradeable, OwnableUpgradeable {
    
      using CountersUpgradeable for CountersUpgradeable.Counter;
       CountersUpgradeable.Counter private _tokenIdCounter;
 IERC20Upgradeable public tokenAccepted;
       constructor() initializer {}
    
        function initialize(address _token) initializer public {
            __Ownable_init();
            __UUPSUpgradeable_init();
            tokenAccepted =IERC20Upgradeable(_token);
           
        }
kool Erick
  • 101
  • 1
  • 6
  • Do you know which line is causing that error? You usually get this error when you try to assign a property to a String. i.e. `address['kind'] = something` where `address` is 0x814bd9012bD1e51b86890343b9731501875502e8 – wxker Apr 03 '22 at 01:19
  • I have no idea, any help to fix it? probably I need to pass the token address as a string around here ``const SmartBInit= await upgrades.deployProxy(SmartB,tokenaddr, {`` ? – kool Erick Apr 03 '22 at 04:03
  • There isn't enough information. Please post the stack trace of the error. – wxker Apr 04 '22 at 06:01

1 Answers1

1

I was passing the parameters in the next smart contract the wrong way, it should be

const SmartBInit= await upgrades.deployProxy(SmartB,[tokenaddr],{}

Instead of

const SmartBInit= await upgrades.deployProxy(SmartB,tokenaddr, {}
kool Erick
  • 101
  • 1
  • 6