Skip to content

vadkutsen/near-petshelter-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pet Shelter Contract

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

Step 0: Install near-cli

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)

Step 1: Create an account for the contract

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:

  1. Authorize NEAR CLI, following the commands it gives you:

    near login

  2. Create a subaccount (replace YOUR-NAME and YOUR-SUB-ACCOUNT below with your actual account name):

    near create-account YOUR-SUB-ACCOUNT.YOUR-NAME.testnet --masterAccount YOUR-NAME.testnet

Step 2: Make sure the contract works as expected - run tests

You can easily test the smart contract code using cargo:

cargo test

Step 3: Build the contract

Assuming that all the tests passed ok, you can go ahead and compile the smart contract:

cargo build --target wasm32-unknown-unknown --release

Step 4: Deploy!

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

About

Extended Near version of a simple Pet Shop contract from Truffle tutorial

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published