zeitgeist
zeitgeist copied to clipboard
Not able to connect contracts ui to local node or upload contract using cargo contracts.
I tried to follow the official Ink guide to create and upload a contract to a local dev node. https://use.ink/getting-started/deploy-your-contract
Couldnt get the contracts ui (https://contracts-ui.substrate.io/) to connect to my local node.
And running the following:
cargo contract build
cargo contract upload --suri //Alice
Resulted in error:
ERROR: ErrorObject { code: ServerError(-32000), message: "Client error: Execution failed: Runtime panicked: Bad input data provided to upload_code: Input buffer has still data left after decoding!", data: None }
Caused by:
ErrorObject { code: ServerError(-32000), message: "Client error: Execution failed: Runtime panicked: Bad input data provided to upload_code: Input buffer has still data left after decoding!", data: None }
Im starting the node locally with this command:
cargo run --release --bin zeitgeist -- --dev --ws-external --pruning archive --tmp
Hey, I tested the exact same commands except for "cargo contract upload --suri //Alice". I could connect to the local node via https://contracts-ui.substrate.io/ and could successfully deploy the contract and could interact with the Flipper Hello World example.
@yornaath
The Contracts UI uses instantiate_with_code internally. So I tried to do the same thing with that command and it worked:
cargo contract instantiate --constructor new --args false --suri //Alice --execute
This uploads and instantiates the code.
For upload_code extrinsic you get this error https://github.com/paritytech/substrate/blob/8c823ecd80ecacff5a967607a68815fecfa12938/frame/contracts/src/lib.rs#L933-L941
So, most likely it's because out node is not up to date or the API for the contracts pallet.. Let me dig into it further.
EDIT: interesting to know that I can upload the WASM contract file directly to the contracts pallet via the extrinsic call. But I assume the crate "cargo-contract" is just too new for our old "polkadot-v0.9.32" contracts API. So my next approach is to use an older crate version for cargo-contract.
The newest version of "cargo-contract" code uses another parameter (determinism) for upload code that we don't have on our current battery station contracts api.
Here is the change we don't want https://github.com/paritytech/cargo-contract/commit/278ff4bc09cd90820b1dc531a78693ffaf7e572d
This is the commit prior to the change: https://github.com/paritytech/cargo-contract/blob/9c7578435d26d5486ba77612f9edcb8a62af080d/crates/cargo-contract/src/cmd/extrinsics/upload.rs#L160-L164
So the fix would be to use an older cargo-contracts code:
cargo install --force --locked cargo-contract --rev 9c7578435d26d5486ba77612f9edcb8a62af080d --git https://github.com/paritytech/cargo-contract.git
But when you do this you'll get an error... So I see no other way than updating our polkadot version in our node and use atm instantiate_with_code instead of upload code. Or you can still upload the code via the direct extrinsic for your local node via polkadot js.