Divi Games

Courses / Using Divi

Your first transaction

On the side-chain, a transaction is a JSON text plus a signature over exactly that text:

{ "body": "{\"v\":1,\"chain\":\"divi-games-testnet-1\",\"from\":\"y…\",\"nonce\":0,\"action\":{\"type\":\"faucet\",\"token\":\"GOLD\"}}",
  "sig": "H3k…" }

The body is a string. The node never re-serialises it; it parses the string, verifies sig as a Divi signed message over those exact bytes, and checks the recovered address equals from. A wallet can therefore show you precisely what you are signing.

The body fields

FieldMeaning
vformat version, 1
chaindivi-games-testnet-1; stops a tx being replayed on another chain
fromyour address
nonceyour account's next nonce, starting at 0
actionwhat to do, e.g. {"type":"transfer", ...}
memooptional, up to 140 characters

The txid is hex(SHA256(body bytes)).

Nonces

The nonce makes each of your transactions unique and ordered. A tx with a wrong nonce or a bad signature never enters the mempool. A tx that is valid but whose action fails, say an illegal move, is included in a block with a failed receipt, and it still uses up its nonce.

Try it

  1. Create or open a key and note its address.
  2. Sign a faucet action for GOLD with nonce 0 and submit it to POST /v1/tx.
  3. Look up GET /v1/tx/<txid> until it has a receipt, then GET /v1/account/<address> to see 1000 GOLD (amounts are shown as base units: "100000").

The SDK (web/sdk/divigames.js) does all of this: signTx(key, {nonce, action}), chain.submit(...) and chain.waitForReceipt(txid).