Moralis Upgradeable Smart Contract Tutorial

alright cool cool, which step are you in right now?

at the .env step, just so im clear i only add REACT_APP_MORALIS_APPLICATION_ID and REACT_APP_MORALIS_SERVER_URL

not the others ?

1 Like

yepp they are the necessary ones in this tutorial :raised_hands: others are optional, mostly for using the Moralis Admin CLI

1 Like

you da man YosephKS thank you so much for the help

1 Like

Hi @YosephKS,

Thanks for the tutorial, very useful and helpful.

I have a question about upgradeable contracts. I have a “factory” contract which instantiates two other contracts using “new”. So, let us say, contract A instantiates contracts B1and C1. Would it be possible to make the factory (contract A) upgradeable so that it would instead instantiate contracts B2 and C2?

And if that is possible, do contracts B1, C1, B2, C2 need to be upgradeable themselves? or can they be “standard” contracts?

I hope I am explaining myself properly, please let me know if I am not.

Thanks.

Yes great question! @DeveloperMarwan unfortunately a child contract created by a factory contract would not be able to be upgraded :raised_hands: here you can check the docs by OpenZeppelin for mode details on the topic https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#creating-new-instances-from-your-contract-code

complied success!
i am getting this error
PollingBlockTracker - encountered an error while attempting to update latest block:

Hey @zap, it’s pretty normal to have time out error when deploying, you can simply try migrate again and it’ll continue the migration from where it left off, if the node is too unstable that it timeout very frequently, I suggest you try to use public RPC url

Thanks for your Reply!
tried migrate many time but not working
try to deploy to local network but caused me this error
Error: Artifacts are from different compiler runs

problem solved in local network
i have deleted src/contract [folder] and made empty contract [folder]
and change the in truffle-config.js changed network_id: “",
networks: {
develop: {
host: “127.0.0.1”,
port: 7545,
chainId: 1337,
network_id: "
”,

but problem persist with Rinkeby network

yeah if you get error of truffle compile all, just delete the contracts folder and recompile everything, sometimes that happens, and for rinkeby, I think it should already be configured there, you just need to have your Moralis Speedy nodes key (something I named myself), which is something in between the RPC URLs

Hi @YosephKS
Can you share the contracts (Solidity files)?

Hey @niknak, it’s open source and you can find it in the Youtube description or on this thread, just scroll up to the top :raised_hands:

I am having the same issue. Not sure what you are referring to when you say " delete all the ABIs in src/contracts"

Could you please elaborate? I seem to be stuck.

Which issue exactly? He means to find the .json files (ABIs) that are compiled from your contracts and delete them.

when running yarn test I also receive the error
“Error: Artifacts are from different compiler runs Run a full recompilation using truffle compile --all
https://zpl.in/upgrades/truffle-recompile-all”. Even though it compiles successfully outside of yarn test.

So I need to go through the .json files within the src/contracts folder and just make sure every reference to abi is empty? or remove the abi variable all together? and should it be deleted from every .json file in the folder or a specific one?

Sorry I understand the solidity fine. Its the web development aspect and interdependencies that are throwing me off.

So delete those artifact/JSON files that are automatically generated when you compile contracts.

You don’t need to delete any pointers to them in other files; they will be generated again after another compile. You can try that truffle compile --all command also.

Back up your project just in case.

1 Like

Ah! I see. Thank you very much. That worked perfectly. I really appreciate the quick response :handshake:

I successfully run

npm run compile

and

npm run test

However, when running

npm run migrate --network rinkeby

it always fail on error:

> Something went wrong while attempting to connect to the network at http://127.0.0.1:7545. Check your network configuration.

Could not connect to your Ethereum client with the following parameters:
    - host       > 127.0.0.1
    - port       > 7545
    - network_id > 5777
Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" or "--http" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle-config.js)

Truffle v5.5.11 (core: 5.5.11)
Node v16.14.2

I configured MORALIS_SPEEDY_NODES_KEY in my .env file. But for some reason it tries to connect to the localhost. Please, do you have an idea why?

How are you using your speedy node environment variable? Check your Truffle config, the rinkeby network setting is still pointing to your localhost.