Hello, World!

This example shows how to create a smart contract in Rust that prints a greeting.

Usage

cleos push action hello hi '["world"]' -p 'hello@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"
    }
  ]
}