Development Workflow

Create a new NEAR project

# initialise new rust project 
cargo new project_name 

# install near dependencies 
cargo add near_sdk 
cargo add near-contract-standards
cargo add near-sdk-contract-tools

# alternatively, if cargo.toml file with necessary dependencies exists:
cargo fetch 

# build contract files 
cargo build --release --target wasm32-unknown-unknown

# deploy to testnet 
near dev-deploy --wasmFile target/wasm32-unknown-unknown/release/contract.wasm 

Config for cargo.toml

[dependencies]
near-contract-standards = "4.1.0"
near-sdk = "4.1.0"
near-sdk-contract-tools = "0.7.0"

[lib]
crate-type = ["cdylib"]

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
opt-level = "z"
lto = true
debug = false
panic = "abort"
# Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801
overflow-checks = true

Last updated