We have created a command line tool aspect-tool
for boosting the development of Contract and Aspect.
It contains many scripts for quickly building, deploying and invoking. It is a useful tool for developing “rich-dApp” which includes both contract and Aspect.
Executing the following command to install:
# install aspect-tool
npm install -g @artela/aspect-tool
Next, you can initialize your project with the help of aspect-tool
, execute the following commands to initialize:
# create a new directory and enter into it
mkdir my-first-aspect && cd my-first-aspect
# initialize a new npm project
npm init -y
# initialize the given npm project with aspect
aspect-tool init
# install required dependencies
npm install
Here is the layout of the project.
.
├── README.md
├── asconfig.json
├── assembly
│ ├── aspect <-- your aspect here
│ │ └── aspect.ts <-- entry functions of aspect
│ └── index.ts
├── contracts <-- your contract here
├── node_modules
│ ├── @artela
│ │ ├── aspect-libs <-- library of aspect
│ │ ├── aspect-tool <-- aspect-tool, utils of aspect
│ │ ├── web3 <--│
│ │ ├── web3-atl <--│
│ │ ├── web3-atl-aspect <--│
│ │ ├── web3-core <--├── artela.web3js, artela web3 client.
│ │ ├── web3-core-method <--│
│ │ ├── web3-eth-contract <--│
│ │ └── web3-utils <--│
│ ├── @assemblyscript <-- aseemblyscript libs
...
├── package.json
├── project.config.json
├── scripts <-- scripts for depolying & binding contract, e.g. "npm run contract:deploy"
│ ├── aspect-deploy.cjs
│ ├── bind.cjs
│ ├── contract-call.cjs
│ └── contract-deploy.cjs
├── tests
└── tsconfig.json
Create your contract source files, name as *.sol
, in the project’s contracts
directory.
For example, we create a file called Counter.sol
and implement a simple smart contract as the following:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
contract Counter {
uint256 private counter;
// The aspect specification should give overriding the isOwner method.
function isOwner(address user) external view returns (bool result) {
return true;
}
function count(uint256 number) public {
counter = counter + number;
}
}
This smart contract has a function count
, which takes a number and adds the number to an on-chain state variable counter
. We will use this smart contract later with our Aspect.