NetworksNEAR has two main networks for you to use:
testnet and mainnet. The testnet network behaves exactly as the main network but uses test tokens with no real valueTestnet Account
To deploy a contract, you need a testnet account. If you don’t have one, you can create one using the following command:<contractId> with the name you want to give to your account, and make sure it ends with .testnet.
The account will be created with 10 NEAR (these are test tokens).
Testnet FaucetNotice that we are using the
--useFaucet flag to automatically request test tokens from the NEAR faucet.The faucet is only available on the testnet network - which is the default network for the CLIDeploying the Contract
To deploy the contract, you need to compile the contract code into WebAssembly (WASM) and then deploy it to the network- 🌐 JavaScript
- 🦀 Rust
<auctioneerId> with the name of another account, this should not be the same as the contract account as we intend on removing its keys.
Locking the contract
As mentioned previously we should lock the account by removing the keys. This allows our users to interact with the contract without having to trust the account owner.Interacting with the Contract
We are now ready to start bidding by calling thebid function on the contract. We recommend that you create two new accounts to simulate different bidders.
bid function without arguments, but attach 1 NEAR to the transaction. This is the amount we are bidding.
For the get_highest_bid function, we don’t need to specify which user is calling it, as it is a view function and does not require gas to be executed.
Conclusion
We have now seen how to deploy a contract totestnet and interact with it using the NEAR CLI.
A word of advice before moving forward. When people learn how to use the CLI, they get lazy and start testing new contract features directly on the testnet. While this is tempting, it is not recommended.
Do not use testnet as your only way to test contracts. Always test your contracts on the sandbox environment first, and only deploy to the testnet when you are confident that everything is working as expected.