I have tried following instructions from:
https://rustrepo.com/repo/paritytech-substrate-contracts-node
and
https://ink.substrate.io/faq/#how-do-i-print-something-to-the-console-from-the-runtime
My process:
1 - Add debug statements to the contract code:
#[ink(constructor)]
pub fn new() -> Self {
ink_env::debug_println!("created new instance at {}", Self::env().block_number());
Self {}
}
#[ink(message)]
pub fn sayhello(&self) {
ink_env::debug_println!("Hello");
}
2 - build: cargo +nightly contract build
.
OUTPUT:
Original wasm size: 32.7K, Optimized: 11.1K
The contract was built in DEBUG mode.
Your contract artifacts are ready. You can find them in:
/home/IamDeveloper/MySoftwareProjects/blockchain/rust/rust-substrate-blockchain-projects/my-first-substrate-projects/my-first-project-prep-lesson/my-first-smart-contracts/helloworld/target/ink
- helloworld.contract (code + metadata)
- helloworld.wasm (the contract's code)
- metadata.json (the contract's metadata)
3 - In another terminal, run the node:
substrate-contracts-node --dev -lerror,runtime::contracts=debug
4 - In the original terminal, upload:
cargo contract upload --suri //Alice
5 - Get the code hash:
code_hash=0xfd548906549af08bbb8bdd436f46b457d2b6ea9f8b6610e9515b3c4e7fe22d9c
6 - Instantiate:
cargo contract instantiate \
--gas 500000000000 \
--constructor new \
--suri //Alice \
--code-hash $code_hash
7 - Get the Contract:
Contract=5E4V3mvaf2nYKLRJJMNhc6TXrM5GxNwsga4hESRPquCXEyu1
8 - Call:
cargo contract call \
--gas 500000000000 \
--message sayhello \
--suri //Alice \
--contract $Contract
RESULT: No output at all from the terminal running the node.