Tic-Tac-Toe
This example shows how to create a smart contract that reads and writes tables.
Usage
cleos push action tictactoe create '["alice","bob"]' -p 'alice@active'
cleos push action tictactoe makemove '["alice","bob",1,0,1]' -p 'alice@active'
cleos push action tictactoe restart '["alice","bob",1]' -p 'alice@active'
cleos push action tictactoe close '["alice","bob"]' -p 'alice@active'
Cargo.toml
[package]
name = "hello"
version = "0.1.0"
edition = "2018"
publish = false
[lib]
crate-type = ["cdylib"]
doc = false
[dependencies]
eosio = { path = "../../crates/eosio" }
eosio_cdt = { path = "../../crates/eosio_cdt" }
Source
#[eosio::action]
fn hi(name: eosio::AccountName) {
eosio_cdt::print!("Hello, ", name, "!");
}
eosio::abi!(hi);
ABI
{
"version": "eosio::abi/1.0",
"structs": [
{
"name": "hi",
"base": "",
"fields": [
{
"name": "user",
"type": "name"
}
]
}
],
"actions": [
{
"name": "hi",
"type": "hi"
}
]
}