On this page, we will only cover the basics of NEAR CLI. For more information visit the
NEAR CLI documentation page.
Deploying the Contract
Thanks to theNEAR CLI deploying a contract is as simple as:
- Compiling the contract to wasm.
- Create an account and deploy the contract into it using
NEAR CLI.
Compile the Contract
- 🦀 Rust
- 🌐 JavaScript
Create an Account and Deploy
Deploy in an Existing Account
By default
near-cli uses the testnet network. Define NEAR_ENV=mainnet to deploy into mainnet.Naming Convention for Public-Facing Methods
Once the contract is deployed to the network, anyone and any other contract (i.e., any other account on NEAR) can interact with it by calling its methods. Furthermore, any transactions involving the contract will also be included in the network’s data stream, which means its activity can also be visible to any who listens to particular events.Considering this, we advise to name methods using
snake_case in all SDKs as this is compatible with the remainder of the NEAR ecosystem which is predominantly comprised of Rust contracts.Initializing the Contract
If your contract has an initialization method you can call it to initialize the state. This is not necessary if your contract implementsdefault values for the state.
You can initialize your contract during deployment using the
--initFunction & --initArgs arguments.