Interact with the Atoma Smart Contract
Describes the main steps how to interact with the Atoma Smart Contract
In order to interact with the Atoma contract, we provide a set of tools which include a custom cli module for Atoma, that allows anyone to submit transactions into Atoma. Furthermore, node operators can leverage a custom daemon that automatizes many of the processes related to operating a node (we will provide a more extensive description of the daemon functionalities in a later section).
Install Sui cli
1. Install the Sui Client Locally:
The first step in setting up an Atoma node is installing the Sui client locally. Please refer to the Sui installation guide for more information.
After installing the Sui client, connect to a Sui RPC node to be able to interact with the Sui blockchain and therefore the Atoma smart contract. Please refer to the Connect to a Sui Network guide for more information.
Next, create a wallet and fund it with some testnet SUI. Please refer to the Sui wallet guide for more information. If you plan to run the Atoma node on Sui’s testnet, you can request testnet SUI tokens by following the docs.
After completing the steps above, you should have the following files created locally:
-
~/.sui/sui_config/client.yaml
- the Sui client configuration file. -
~/.sui/sui_config/sui.keystore
- The Sui keystore file (contains your private key(s)).
Request Sui testnet funds by running the command:
You can query your wallet balance through
Atoma Testnet Parameters
-
Atoma’s package id (on Sui’s testnet):
0xfa971724b5fb14c2ffc9a959b81cce4d85d457da27e29f793e12428ed71bb922
-
Atoma’s DB object id:
0xe0b1d6458f349d4bc71ef119694866f1d6ee6915b43f8cc05a5d44a49e3e1f0f
-
USDC faucet token package id (testnet):
0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29
Set up Atoma’s Custom cli
To interact with the Atoma contract through our custom cli, follow these steps:
- Clone the Atoma contract repository:
The current Atoma contract relies on USDC
for payments. In order to start interacting with the Atoma contract, you need to request USDC
tokens to your (local) active Sui wallet.
In order to do so, you can request Sui testnet USDC
tokens to your (local) active Sui wallet, via the url:
Once you have requested the tokens, you should be able to query the value amount of USDC
tokens you currently hold on your wallet:
Notice that the USDC
uses 6 decimal places, which means that to 1 USDC
is represented logically on the Sui blockchain through an amount of 1000000
.
Tasks on Atoma
Tasks on Atoma specify compute jobs on the network. Each Task
is assigned a role. Roles can be one of the following values:
-
Chat completions - 0
-
Embeddings - 1
-
Vision - 2
-
Image generation - 3
-
Text to speech - 4
-
Speech to Text - 5
-
Fine tuning - 6
-
Training - 7
To spawn a new Task
on Atoma, specify a model (following HuggingFace name convention), for example:
model-name: meta-llama/Llama-3.3-70B-Instruct
You can specify an optional Security level
for the Task
:
-
No security - 0 (meaning no additional security requirements like verifiability or privacy are required)
-
Confidential compute - 1 (meaning that the each workload on Atoma for this task is performed within proper TEEs, for both verifiable and private AI)
-
Sampling Consensus - 2 (meaning that each workload on Atoma for this task requires
Sampling Consensus
to be executed, allowing for verifiable AI through crypto-economics guarantees).
The Task
creator can also specify a minimum node reputation score (minimum 0 and maximum 100).
In the current testnet version, Task
s can only be spawned by the administrator of the Atoma contract. In the future, tasks will be part of Atoma’s governance protocol. Moreover,
tasks can either be public or private. Public tasks can be subscribed by any node on the network (more below), whereas private tasks can only be subscribed by nodes that have been granted access by the administrator,
that is, that have been whitelisted by the administrator.
In order to submit to create a Task, using Atoma’s cli, one simply needs to run:
When a transaction for creating a new Task is submitted, the involved wallet receives a new Sui Move object, of the form:
The TaskSmallId
is a wrapper around a u64
number
This number is important to refer to the task in future transactions such as subscribing nodes to tasks, deprecated or remove tasks, buy Stacks on behalf of a user, etc.
Deprecating Tasks
It is possible to deprecate tasks that are active, and were created by the current wallet by running:
The TASK_BADGE_ID
value is the id within TaskBadge
that can be accessed by querying the wallet owned objects.
Removing Tasks
To remove a task that was already deprecated, one can run the command:
Register a Node
The easiest way to register a node on the Atoma contract is through the Atoma node daemon. However, it is also possible to register a node manually through the Atoma cli. In order to register a node on Atoma,
Once the node is registered, the node will receive a NodeBadge
object of the form:
the NodeSmallId
is a wrapper around a u64
number
which is a unique identifier that allows the Atoma contract to select different nodes for different tasks workloads.
Subscribe a Node to a Task
In order for Atoma nodes to participate in the protocol, these must subscribe to specific tasks:
The price-per-one-million-compute-units
is the price to which the node is willing to be paid for 1 million compute units. More concretely, in the example above, if task-small-id
1 is a Chat completions
task,
say for meta-llama/Llama-3.3-70B-Instruct
, then the subscribed node is charging a price of 1 USDC
for 1 million (LLM) tokens for the model meta-llama/Llama-3.3-70B-Instruct
.
Unsubscribe a Node from a Task
Nodes on Atoma can unsubscribe from Tasks that these have subscribed to (even though nodes must claim each active Stacks):
Buy Stacks
Users on Atoma can access nodes, by first buying Stack
s associated to a specific Task
. In order to buy a Stack
, one just needs to run the command:
The price
is the price per one million compute units to which the user is willing to pay for. In the example above, assuming that task-small-id
1 refers to a Chat completions
task,
under the meta-llama/Llama-3.3-70B-Instruct
model, then the user is willing to pay 1 USDC
for 1 million compute units (that is, 1 million LLM tokens, roughly words).
Once the Stack
is acquired by the wallet, the wallet will hold a StackBadge
object of the form:
This object grants permissions to the wallet to manage the Stack
. The StackSmallId
is a wrapper around a u64
, which can be used to refer to the Stack
later, as we shall see.
Settling Stacks
Once nodes have processed a large number of compute units for a given Stack
, the nodes can try to settle the Stack
and claim the funds for having provided the compute to the holder of the Stack.
The first step to settle a Stack
is by trying to settle the stack:
The values of committed-stack-proof
and stack-merkle-leaf
can be computed as the Merkle tree root and leaf index corresponding to the whole Stack
history.
In practice, node operators do not need to compute these values themselves, as this is completed addressed within the Atoma node daemon logic.
Once the transaction goes through, a dispute challenge window for the Stack
execution starts, which lasts for two epochs. Within those epochs anyone can dispute the Stack
settlement,
including user holding the original Stack
. Additionally, the Atoma contract can select one or more nodes to attest to the right execution from the original selected node for the Stack
This is relevant, and only required, for our Sampling Consensus protocol. If no security or confidential compute security are associated to the Stack
, then the contract skips this step.
If a node is selected to attest a Stack
execution, it needs to fetch the Stack’s input data, and redo the whole history of execution (that is, running AI inference on the whole stack requests). Once that is done, the node can attest the execution by submitting an on-chain transaction as:
On the other hand, any participant on the network can start a dispute mechanism as:
In this case, a dispute resolution mechanism is put forth by the contract to resolve the dispute. The dishonest part involved in the dispute resolution mechanism will be at risk of slashed collateral.
Claim Funds
Once the dispute challenge period has finished for a Stack
, the node can finally claim its funds by running the command: