This repository includes NEAR smart contract written in Rust programming language. The smart contract allows to add pets, adopt pets and donate Near. UI repository for the project can be found here: https://github.com/vadkutsen/near-petshelter-ui
near-cli is a command line interface (CLI) for interacting with the NEAR blockchain. To install it globally:
yarn install --global near-cli
Or, if you'd rather use the locally-installed version, you can prefix all near
commands with npx
Ensure that it's installed with near --version
(or npx near --version
)
Each account on NEAR can have at most one contract deployed to it. If you've already created an account such as your-name.testnet
, you can deploy your contract to your-sub-account.your-name.testnet
. Assuming you've already created an account on NEAR Wallet, here's how to create your-sub-account.your-name.testnet
:
-
Authorize NEAR CLI, following the commands it gives you:
near login
-
Create a subaccount (replace
YOUR-NAME
andYOUR-SUB-ACCOUNT
below with your actual account name):near create-account YOUR-SUB-ACCOUNT.YOUR-NAME.testnet --masterAccount YOUR-NAME.testnet
You can easily test the smart contract code using cargo:
cargo test
Assuming that all the tests passed ok, you can go ahead and compile the smart contract:
cargo build --target wasm32-unknown-unknown --release
For development purposes you can use dev-deploy
command and your smart contract will be deployed to the live NEAR TestNet with a throwaway account:
near dev-deploy --wasmFile target/wasm32-unknown-unknown/release/YOUR_CONTRACT_NAME.wasm
When you're ready to make it permanent, here's how:
near deploy --wasmFile target/wasm32-unknown-unknown/release/YOUR_CONTRACT_NAME.wasm --accountId YOUR_ACCOUNT_HERE