Guides / Hands-on

Deploy a first contract to the testnet

Compile a WASM contract, set it on an account and call an action.

Wire runs WASM smart contracts with the Antelope contract model: you compile C++ to a .wasm plus an .abi, set both on an account and the account becomes the contract. This guide deploys a minimal contract to the V2 testnet.

What you need

  • A funded testnet account (faucet guide).
  • The Antelope Contract Development Toolkit (CDT) if you compile locally, or the contract deploy tool in the pre.wire.network suite if you prefer the browser.

A minimal contract

#include <sysio/sysio.hpp>

class [[sysio::contract]] hello : public sysio::contract {
public:
  using contract::contract;

  [[sysio::action]] void greet(sysio::name user) {
    sysio::print("hello, ", user);
  }
};

One action, no state. The [[sysio::action]] attribute exports greet so it can be called from a transaction. Compile it with the CDT and you get hello.wasm and hello.abi.

Deploy

  1. Open the contract deploy section at pre.wire.network with MetaMask connected, or use your preferred Antelope CLI pointed at https://testnet-api-use1.dev.wire-dev.com.
  2. Upload or paste the .wasm and .abi for your account.
  3. Confirm the set-code transaction. Your account now answers as a contract; calling greet is just another transaction with your account as the code target.

Verify the code is live

curl -X POST https://testnet-api-use1.dev.wire-dev.com/v1/chain/get_code_hash \
  -d '{"account_name":"youraccount"}'

A non-zero code hash means the chain is running your WASM. To read a deployed contract's interface, get_abi with the same body returns every action and table it exposes - useful for exploring the system contracts too.

Notes from my own runs

  • RAM for contract storage comes from your account's resources. On the testnet the default allocation covers a small contract; a bigger one may need a policy bump, which the next guide covers.
  • Deploying over an existing contract replaces the code but tables persist. Plan migrations before you need them, even on a testnet.
Testnet deployments are practice runs on a network that can be reset. Treat every deployment as disposable and keep your source under version control off-chain.