# Trustless Flow

You can run an AMA integration using purely the RPC and its quite reliable.\
\
You also need to download the latest binary release of the node and run it as `OFFLINE=true ./amadeusd`, it functions as a utility tool similar to `geth`.

Get the current chain height and hash from your integrations inception:

```
curl -s https://nodes.amadeus.bot/api/chain/stats \
| jq -r '.stats.tip.header_unpacked.height'

34959084

curl -s https://nodes.amadeus.bot/api/chain/stats \
| jq -r '.stats.tip.hash'

BENtrybSL5UGBnjJMm7sVZ9fr1CN7Qu9R3SdH88GxdEt
```

Next generate deposit wallets as required:

```
./amadeusd --bw-command start generate_wallet

5ibhX6qynQvFuBaQH1phfqCCY3VKMw4kLXkcSeBCNeAyCpyMVYzsEWx9FNBu6yz2XF
3CHRgeHNDzg3qjnFGdruvXqVb45TAWXzGZpnK2mKKHaByy7ZiQUMaDjLbQu1z4AnfsNtN2diM6Tc9PBVPgWZ7zgL
```

Check for finality and scan the block for deposits or withdrawls:

```json
curl -s https://nodes.amadeus.bot/api/chain/hash/BENtrybSL5UGBnjJMm7sVZ9fr1CN7Qu9R3SdH88GxdEt?filter_on_function=transfer \
| jq -r '.entry.consensus.finality_reached'
true

curl -s https://nodes.amadeus.bot/api/chain/hash/BENtrybSL5UGBnjJMm7sVZ9fr1CN7Qu9R3SdH88GxdEt?filter_on_function=transfer \
| jq -r '.entry.txs_filtered'
[
  {
    "metadata": {
      "entry_hash": "BENtrybSL5UGBnjJMm7sVZ9fr1CN7Qu9R3SdH88GxdEt",
      "entry_slot": 34959084
    },
    "signature": "231XbxmVFKYNJsFb8X49wGAx1HVbW7FuiNFzVxuF1BCey5SpdsRzaSYRzTJEdJ22XF8g3NfzJgqnMrgypxZYbVV3hJWVTqRukY6C6cnPYNDbUTyu2gHVyQvNqRUkNfCmmi58",
    "hash": "6NxepwR3YTf3JbNoTtycZ73eLmY79CFzhueFJdYvDsoE",
    "tx": {
      "nonce": 1760628863344857048,
      "signer": "69TDon8KJp3vicNeFR3dg5x5sKY8PJFLmoizX3RN31YL4fwr266AVcXgwy1mjCLy6M",
      "actions": [
        {
          "args": [
            "5tUw2maGeGEvNyn6hkwssyNgiEd7K4Dp6jtkDFTSkbHZGiWR4Q12JMpbtC3n3r8cef",
            "64516000000000",
            "AMA"
          ],
          "function": "transfer",
          "op": "call",
          "contract": "Coin"
        }
      ]
    }
  }
]

```

Parse the single relevant transfer transaction now:

```
 Sender: "69TDon8KJp3vicNeFR3dg5x5sKY8PJFLmoizX3RN31YL4fwr266AVcXgwy1mjCLy6M",
 Receiver: "5tUw2maGeGEvNyn6hkwssyNgiEd7K4Dp6jtkDFTSkbHZGiWR4Q12JMpbtC3n3r8cef"
 Amount: 64516000000000 (9 decimals)
 AmountAsFloat: 64516.0  (64516000000000 / 1_000_000_000)
```

Check if there is another block after that has reached finality and repeat.

```
curl -s https://nodes.amadeus.bot/api/chain/hash/BENtrybSL5UGBnjJMm7sVZ9fr1CN7Qu9R3SdH88GxdEt?filter_on_function=transfer \
| jq -r '.entry.next_entry_hash_finality_reached'
789CfwfidnT44vVgGWz7xnm8CB7VLxBYMkUPeGAysWD2
```

To process a withdrawl now create a serialized transaction substituting the SEED64= envvariable for your `sender seed/privatekey` as base58, then 69receiver as the receivers public key in base58, amount here cannot be float it must be the full integer accounting for 9 decimals.

<pre><code><strong>SEED64=sender ./amadeusd --bw-command start buildtx Coin transfer ["69receiver", "1000000000", "AMA"]
</strong>
jKhTr4KjP2rsAGvtHfsX7h5MbBeKt1WbL78N3KVofpRc4f85UBjNhdMJH9AndZLEQpRsg5BcZLQ
CGiYCK7k7hchJcmmBh4cjZDkWzSSpcHenqZrb5tKPRdXDx1Xin13MzKQPukmGDQzgMUzkC2RzQv
DrJJmY7CJqcXPF7QCJrAuHBqyv79ysGnRugkReHwkCRyd99hXwkWeFYHeS1aBLAntpmFwqzc2bD
ANTms9Har4WgEX3pDs32mwCDsTJ3nYPbRAee1Gp77CuZPa9fQsVEGoskFz5xrf2kCXjBG8NhdN1
X5NNfGV5vZDYDt9J3oYG1Z3Z6yWzbv5pbhnkMupiFShSAiXssVa2H7MhozQ2xrtxyNhrtHQGrd5
NAA8dnfNCXYQ2enHtJFFzg6vP2Zajye87BwCxvVv4TELjBKs1ajBqVrrMiT411KhAL1yn1NnTji
RjhEfRyPvh5Mpnu1YoAVvhQFtYCUMWK9y7

%{
  signature: &#x3C;&#x3C;165, 29, 132, 117, 78, ...>>,
  hash: &#x3C;&#x3C;224, 102, 230, 139, 81, 81, ...>>,
  tx: %{
    nonce: 1761339817312206803,
    signer: &#x3C;&#x3C;180, 138, 83, 27, 27, ...>,
    actions: [%{
      args: ["69receiver", "1000000000", "AMA"], 
      function: "transfer", 
      op: "call",
      contract: "Coin"}]
  },
  tx_encoded: &#x3C;&#x3C;7, 1, 3, 5, ...>>
}
</code></pre>

Call a similar API `build_and_broadcasttx` to directly broadcast it to an RPC node:

```
SEED64=sender ./amadeusd --bw-command start build_and_broadcasttx Coin transfer ["69receiver", "1000000000", "AMA"]

78VMtHDJCtmFohiRNAS89g3pQNvhmtN6KZ4jyGhe74Xr
```

You can now check the TX hash to confirm the RPC node relayed it to a validator and it got included in the chain

```json
curl -s https://nodes.amadeus.bot/api/chain/tx/78VMtHDJCtmFohiRNAS89g3pQNvhmtN6KZ4jyGhe74Xr | jq
{
  "metadata": {
    "entry_hash": "8k3HVDQ6cqrbFr8hPcdZV1Tos6UykAuMhs6oaJeV1MbP",
    "entry_slot": 36729887
  },
  "signature": "25iZprHk5MZiZi6CXKLFqM5QNJn2UGxLwKD5ZpiLWJH7Y4h1ai3uJgXsjhczipGW2W2fzCEzft8pneiuG4cRojXnfJ1XeWyAEXMAPQh3Xb1ojJaUV4XyF8iWa6gZgDosdy3i",
  "result": {
    "error": "ok"
  },
  "hash": "78VMtHDJCtmFohiRNAS89g3pQNvhmtN6KZ4jyGhe74Xr",
  "tx": {
    "nonce": 28612872,
    "signer": "6KFVHM35azmepNw4MEzDPb65WhjU28oJjTaz9V7QYeCCTVAASHzFUhUiMC2njmUwCS",
    "actions": [
      {
        "args": [
          "wqvhdreKnJ3fN45PqmoBwMC..."
        ],
        "function": "submit_sol",
        "op": "call",
        "contract": "Epoch"
      }
    ]
  }
}

```

The only part missing is to prove the RPC is not lying in a trustless way. This is beyond the scope right now of this guide and protocol upgrades are underway as well.\
\
Of course the best way now is to run a personal node and you can follow the validator guide for that.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ama.one/exchanges/trustless-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
