Note: The best development experience is under the MacOS system

1. Download and install robin integrated development framework

sudo npm install -g robin-framework

Type robin or robin -h or robin --help,and there help information outing,it means robin framework has been installed successfully;
image

If you are prompted that the version of robin is too old,please install robin again:

2. Initialize a contract project and install dependencies using the robin command line

2.1. First create an empty directory and cd to the new directory to execute:

robin init

or

robin init --name MyContract

2.2. Then install dependencies via npm:

npm install

2.3. Finally, open the contract project the IDE WebStorm or VsCode

3. Download and install the longclaw local desktop chain environment

3.1. Longclaw depends on the docker environment, please install docker first, if it is installed, please skip this step;

Download and install from docker center: https://docs.docker.com/docker-for-mac/install/

3.2. If you already have a docker environment, please add docker's China warehouse image address.

For users using macOS, click the Docker for mac app icon -> Perferences... -> Daemon -> Registry mirrors in the taskbar. Fill in the accelerator address https://registry.docker-cn.com in the list. After the modification is complete, click the Apply & Restart button and Docker will restart and apply the configured mirror address.

image

3.3. Download the longclaw installation file from the developer portal

image

3.4. Install and start longclaw, this process takes about two minutes to build a local consensus network environment and initialize data

image

4. Develop a contract with reference to developer documentation and contract templates

4.1. Development documentation reference developer portal

4.2. Development Support Forum

image

5. Use robin for syntax and security checks and bug fixes

> robin lint

robin lint The command will automatically check for syntax errors and try to fix it.。

image

6. Compile contract for webassembly target format file

If the test cases are passed, the next step is to compile and run the command:

> robin build

robin build will generate *.abi, *.wast, *wasm three target files。

7. Deploy contract target files to longclaw(local ultrain environment)

> robin deploy

Before executing robin deploy, you need to modify or confirm the configuration information related to chain interaction, such as configuration items: httpEndpoint, logger, broadcast, sign, chainId, keyProvider etc.

Note: httpEndpoint and httpEndpoint_history are the ultrain realtime api service node and history api service node, If you have a longclaw running, you need not to change them. The chainId you can get using u3, like

    const u3 = createU3();
    await u3.getChainInfo((err, info) => {
       console.log(info);
    });

If the deployment is successful, the corresponding transaction information will be displayed in longclaw, and after 10 seconds, the block confirmation message will be generated.

8. Write test cases with tools such as u3.js and u3-utils

Test cases can be written with reference to token.spec.js or index.test.js in u3.js. At the same time, it relies on tools such as u3-utils. Run test cases to use commands:

> robin test 

9. Deploy the contract to the test network and the main network separately for contract accuracy verification