Deploying (Windows)

Hi,

I’m trying to deploy my test smart contract to the testnet.
I have an account on the testnet with GTU on it but I’m unsure of how to deploy the contract.

I think that the description in the documentation samples is rather vague, at least it doesn’t describe the node to deploy through, which I assume is required in some way?
Also the account that is to be used for deployment is mentioned by it’s name… also seems a little too simple naming?

https://developer.concordium.software/en/testnet/smart-contracts/guides/deploy-module.html

Hi petlan,

The guide assumes that you are running your own node. The guide for doing so on Windows is here. You can connect to another node that you have gRPC access to, but Concordium don’t run any publicly gRPC-accessible nodes. You may need to add --grpc-ip 127.0.0.1 --grpc-port 10001 to the concordium-client command line in order to connect to the node. (This is based on the default configuration of a local testnet node on Windows.)

To use your accounts with the concordium-client tool, you will need to export them from the mobile wallet and import them with concordium-client config account import FILE (see here). Once they are imported, you can use the concordium-client to send transactions from them, including deploying or interacting with smart contracts.

Ok, I have now exported my mobile wallet account and imported it into my development PC.
Here is the output:

[my_user_name] = my Windows user name.
[my_account_id] = my account id.
[my_account_name] = my account name.

Adding account [my_account_id] with name(s) '[my_account_name]'.
Creating directory 'C:\Users\[my_user_name]\AppData\Roaming\concordium\accounts\[my_account_id]'.
Created key directory.
Writing file 'C:\Users\[my_user_name]\AppData\Roaming\concordium\accounts\names.map'.
Added name mapping: '[my_account_name]' --> '[my_account_id]'.
The keys were successfully written to disk.

So this looked like evrything went well.

Then I try to deploy the module using the concordium client (on Windows) to deploy onto a node (on Ubuntu) which runs on the testnet.

I get an error though:

Deploy the module 'C:\Users\[my_user_name]\projects\piggy_bank3\target\concordium\wasm32-unknown-unknown\release\piggy_bank3.wasm' and name it 'sc_piggy_bank_3'.
Allowing up to 12264 NRG to be spent as transaction fee.
Confirm [yN]: y
Deploying module...
concordium-client_1.1.1-0: user error (account '[my_account_id]' not found)

So somehow the client doesn’t seem to be able to find the client that it just imported, or am I missing something?

PS. my concordium client is located on another drive than the C drive, if that makes a difference.

For the --sender, you should specify the account name (i.e. [my_account_name]) rather than the account address.

I did specify the account name by [my_account_name], not the id - I don’t know why error message refers to the account id [my_account_id].

Could it have something to do with the node maybe being under catch up processing? - my test node isn’t online 24/7.

My command:

concordium-client_1.1.1-0 module deploy "C:\Users\[my_user_name]\projects\piggy_bank3\target\concordium\wasm32-unknown-unknown\release\piggy_bank3.wasm" --sender [my_account_name] --name sc_piggy_bank --grpc-ip 192.168.1.18  --grpc-port 10001

The error response is still as follows with the [my_account_id] even though I don’t mention it anywhere in my command.

Using default energy amount of 12264 NRG.
Deploy the module 'C:\Users\[my_user_name]\projects\piggy_bank3\target\concordium\wasm32-unknown-unknown\release\piggy_bank3.wasm' and name it 'sc_piggy_bank'.
Allowing up to 12264 NRG to be spent as transaction fee.
Confirm [yN]: y
y
Deploying module...
concordium-client_1.1.1-0: user error (account '[my_account_id]' not found)

Yes, it is likely that this is a problem if your node is not caught up with the chain. I checked, and this error indicates that the node is not aware of this account on the chain, which can certainly be the case if it has not caught up to the point where the account was created. It should work once the node is up-to-date with the chain.

It seems that the catch up was the problem, at least for now. Because at the moment I’m waiting for the transaction to be comitted and it has taken some time so far. I’m wondering if it will ever finish.

Transaction '8319515e674e8a8118be6e2ef55ecdf8e61fcc70b26d6add6cada159181a9589' sent to the baker.
Waiting for the transaction to be committed and finalized.
You may skip this step by interrupting the command using Ctrl-C (pass flag '--no-wait' to do this by default).
The transaction will still get processed and may be queried using
  'concordium-client transaction status 8319515e674e8a8118be6e2ef55ecdf8e61fcc70b26d6add6cada159181a9589'.
[12:38:03] Waiting for the transaction to be committed........................................................................................................................................................................................................................................................................................................................................................................................................

Ok, it took quite some time, but in the end it finally went through.

Transaction is finalized into block 5ea7a963b8ffaf71050d967857faee8ba3e4c6bd6173bf19b1ceb2697553e56a with status "success" and cost 0.681278 GTU (12263 NRG).
[12:57:22] Transaction finalized.
Module successfully deployed with reference: '68ca306a53ea6b206a169788b1bb0e98fcc486ad36d949b6dad287df1f2dc79f'.
Module reference 68ca306a53ea6b206a169788b1bb0e98fcc486ad36d949b6dad287df1f2dc79f was successfully named 'sc_piggy_bank'

If your node was catching up during that time, that would explain the long wait. Probably the transaction was already on the chain long before, but your node could not see it was committed or finalized until it caught up. (You would probably be able to see it in the mobile wallet, however.)