multiversx / mx-sdk-py-cli

Python Command Line Tools and SDK for interacting with the MultiversX blockchain and dApps.
Other
35 stars 36 forks source link

upgradeContract produces invalid function (not found) #385

Closed Buky33 closed 6 months ago

Buky33 commented 6 months ago

Installed last versions :

Created an empty new contract with : $> mxpy contract new --name staking-contract --template empty

Deployed on devnet with classical : $> mxpy --verbose contract deploy ...

Then a simple upgrade on devnet : $> mxpy --verbose contract upgrade ... https://devnet-explorer.multiversx.com/transactions/3baaf39aa87392daaea535ede005af4340ccaf210dc23fe066a63218e38cbe9c

This produces an error "[invalid function (not found)] [upgradeContract]"

andreibancioiu commented 6 months ago

Hello!

In your contract, add the following:

#[endpoint]
fn upgrade(&self, new_value: BigUint) {
    self.sum().set(new_value);
}

For example: https://github.com/multiversx/mx-contracts-rs/blob/main/contracts/adder/src/adder.rs

Make sure to follow the documentation here: https://docs.multiversx.com/developers/developer-reference/upgrading-smart-contracts/#sirius-mainnet-release---version-160

Thank you :pray:

Buky33 commented 6 months ago

Ohh yes! there is a new #[upgrade] type for upgrades! Many thanks my friend 🤝