Skip to content

Latest commit

 

History

History

rooch

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Movescriptions on Rooch

Test

  1. Install rooch
cargo install --path .
cargo install --git https://github.com/rooch-network/rooch rooch 
  1. Start server
rooch server start
  1. Deply Modules
rooch move publish --named-addresses movescriptions=default
  1. Deploy MRC20
rooch move run --function default::mrc20::deploy --args object:default::movescription::TickRegistry --args object:default::mrc20::MRC20Store --args string:move --args u64:2 --args u256:21000000 --args u256:1000 --args u64:18
  1. Get PoW input
rooch move view --function default::movescription::pow_input --args address:default --args string:move --args u256:1000 
{
  "vm_status": "Executed",
  "return_values": [
    {
      "value": {
        "type_tag": "vector<u8>",
        "value": "0x4c6d6f7665e8030000000000000000000000000000000000000000000000000000000000005078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef10810200000000000000"
      },
      "decoded_value": "0x6d6f7665e8030000000000000000000000000000000000000000000000000000000000005078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef10810200000000000000"
    }
  ]
}
  1. Calculate PoW
movescription pow -i 0x6d6f7665e8030000000000000000000000000000000000000000000000000000000000005078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef10810200000000000000 -d 2
Nonce: 100000difficulty: 2, hash: 0000ba3600fc7f2276c11b1c1bf207dc263493a40f4e70d2021784e8652c797c, nonce: 170095, use millis: 101

Validate the nonce

rooch move view --function default::movescription::validate_pow --args address:default --args string:move --args u256:1000 --args u64:2 --args u64:170095
{
  "vm_status": "Executed",
  "return_values": [
    {
      "value": {
        "type_tag": "bool",
        "value": "0x01"
      },
      "decoded_value": true
    }
  ]
}
  1. Mint MRC20
rooch move run --function default::mrc20::mint --args object:default::mrc20::MRC20Store --args string:move --args u64:170095 --args u256:1000 
  1. Query state

Get the active account address

rooch account list 

Query the state via rooch_queryGlobalStates

rooch rpc request --method rooch_queryGlobalStates --params '[{"object_type":"${your_active_account_address}::movescription::Movescription"},null, "200", true]' 
{
  "data": [
    {
      "object_id": "0x99891854b64a32266444c444a4ad8ace2fcdb0372178eea65e6f3c4806a18def",
      "owner": "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081",
      "flag": 0,
      "value": {
        "abilities": 12,
        "type": "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::movescription::Movescription",
        "value": {
          "metadata": {
            "abilities": 7,
            "type": "0x1::option::Option<0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::movescription::Metadata>",
            "value": {
              "vec": []
            }
          },
          "tick": "move",
          "value": "1000"
        }
      },
      "object_type": "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::movescription::Movescription",
      "key_type": null,
      "size": 0,
      "tx_order": 2,
      "state_index": 0,
      "created_at": 0,
      "updated_at": 0
    }
  ],
  "next_cursor": {
    "tx_order": 2,
    "state_index": 0
  },
  "has_next_page": false
}