Folder structure to develop Near smart contract using assembly language.
- Install
Node 14
- npm init
- npm i -g near-cli
- npm i --save-dev 'assemblyscript@^0.19.3'
- npx asinit .
- npm i --save-dev @as-pect/cli
- npx asp --init
- npm i near-sdk-as
- npm i near-sdk-core
- update
as-pect.config.js
and importnear-sdk-as/imports
- replace asconfig.json content by
{
"entry": "assembly/index.ts",
"options": {
"binaryFile": "out/main.wasm"
},
"extends": "near-sdk-as/asconfig.json"
}
- npx asp
- near login
- code
~/.near-credentials/testnet
- Delete
tests
folder - Add
out
folder. - Import near-sdk-as types: add a new file
assembly/as_types.d.ts
then copy/past this code
/// <reference types="near-sdk-as/assembly/as_types" />
- Add a file
deploy.sh
- run
chmod +x deploy.sh
- copy/past this code
#!/bin/bash
near deploy --accountId "account_id" --wasmFile "out/main.wasm"
- Deploy:
./deploy.sh
- view contract storage:
near view-state "account_id" --finality final
- create a Tx:
near call method_name '{args}' --accountId "account_id"
- view data:
near view account_id method_name '{args}'
- Tx status:
near tx-status hash --accountId account_id