Hi everyone, I hope this topic fits in here…
I am facing a strange issue when trying to migrate ERC1155Upgradeable in truffle. The console goes BONKERS! When I remove the call for the initialize() everything works fine. But when it get’s called in the migration file:
Any Help much appreciated
Environment
Truffle, ERC1155Upgradeable, OwnableUpgradeable
Details
migrations
const Token = artifacts.require(“MyToken”);
module.exports = async function (deployer, network, accounts) {
deployer.deploy(MTD, {from: accounts[0]});
var Token = await MTD.deployed();
console.log("Deployed at address: " + Token.address);
await Meme.initialize(); //This causes the weird behaviour. The migration fails. When removed, everything goes fine....
};
Code to reproduce
1 Like
UPDATE: BOOM! Big celebreations over here
Thanks to @nventuro 's reply in THIS POST I could get it to work!
It seemed like it has something to do with truffle not handling function overloads not nicely when calling functions in the migration after deploying. But they introduced a fix that goes like this:
`await myContract.methods['initialize()']({ from: accounts[0] });`
use the methods property!
2 Likes
Unfortunately it only fixed it for the initialize() call, for any additional call, the same problem occurs 
So it is not the final solution.
1 Like
Hi @ThomasEnder,
If you are deploying an upgradeable contract, I recommend using OpenZeppelin Upgrades Plugins: https://docs.openzeppelin.com/upgrades-plugins/1.x/truffle-upgrades
The plugins will check upgrade safety, deploy a ProxyAdmin and proxy for you, and call your initialize function as part of the deployment (otherwise you would need to protect it from being called by someone else).
You can also use the following example:
OpenZeppelin Upgrades: Step by Step Tutorial for Truffle
1 Like
Thank you @abcoathup I am following the tutorial and will hopefully be able to test on testnet successfully today
1 Like