moxConsoleDocsAPIStart

Getting started

The public testnet, from a wallet to a contract you deployed. It costs nothing: testnet MUR has no value.

1. A wallet

  1. Open the console and choose Create a wallet. Write down the 12 words and confirm them.
  2. Set a password. It encrypts the phrase on this device; only the phrase recovers the wallet. The wallet locks on reload and when idle.

2. Test MUR

Open Faucet and request funds for your account (limited per address and per IP). Then send some to a second account on the Wallet page: every transaction is shown decoded, with its dry run and fee, before you confirm.

3. Look around

4. Deploy a contract

A Mox contract is a WebAssembly module whose exported functions are its API, with a .mxi interface that declares its state, functions, events and errors. Open Contracts, upload the .wasm (and its .mxi unless the module embeds it), confirm, then call its functions from forms generated from the interface. Standard contracts (such as mrc20) can be created without uploading anything.

5. Write your own

Today the toolchain is built from the repository (releases are coming):

cargo build --release -p mox-cli
rustup target add wasm32-unknown-unknown
mox new counter && cd counter
./build.sh test      # tests on an in-process chain, milliseconds each

Then upload target/wasm32-unknown-unknown/release/counter.wasm on the Contracts page, or deploy from the CLI with mox deploy.

6. From code

Everything the console does goes through the gateway at https://api.mox.network. With @mox/sdk (in the repository; npm soon):

import { load, Mox, Wallet } from "@mox/sdk";

await load();
const mox = new Mox("https://api.mox.network");
const me = Wallet.create().account(0);
await mox.waitReceipt((await mox.faucet(me.address)).hash);
const gold = await mox.create(me, "mrc20", ["Gold", "GLD", 2, 100000, null]);
await gold.view("balance", [me.address]);

A dApp on its own origin can use the console as its wallet: it opens the console in a popup, the person approves the site, and each call is confirmed there. The dApp never sees a key.

Reference