Darwin Quickstart
This guide provides a step-by-step guide for quickly interacting with the Darwin AI blockchain platform.
Note:
This guide ensures that system integrity and user identity are maintained throughout the transaction process.
Prerequisites
Prepare Your EVM-Compatible Wallet: Ensure your wallet supports EVM standards and can interact with Ethereum-based smart contracts. We recommend using MetaMask.
Add Darwin Chain Network:
Visit the Darwin Chain website.
Scroll down -> click the Add Darwin Chain button.
Acquire $DNA Tokens:
Visit the Darwin Faucet at
https://darwin-faucet.example.com
You can participate in staking and transactions to obtain initial $DNA tokens.
Quickstart
Step 1: Create and Submit a Stake Transaction
Use the ether.js
to connect to the contract and call the stakeDNA
function:
Note:
The Darwin Staking Contract Address is 0x123...def
.
Step 2: Sign and Submit AI Transactions with EIP-712
This step details how to securely structure, sign, and submit an AI transaction using the EIP-712 standard with ethers.js
.
Note:
To ensure security and clarity, the EIP-712 typed data structure includes detailed parameters explicitly declared and signed by the user. This structure verifies the authenticity of transaction data sent to the blockchain.
Define the domain and the types:
Note:
Domain: Specifies the contract and network for the transaction, enhancing security by binding the signature to a specific environment.
Types: Defines the data structure to be signed, ensuring clarity and security.
Define the conversation in a structured format, with each entry specifying the role and the corresponding input, encapsulating the interaction sequence:
Note:
The available roles are:
User
System
Assistant
Sign the transaction:
Submit the signed transaction to the Relayer:
Step 3: Retrieve Streaming AI Results from the Query Mixer
Retrieve the AI-generated results from the Query Mixer using your unique requestId
:
Note:
This requestId,
generated during transaction submission, is essential for fetching real-time streaming responses from AI nodes.
Note:
The header "Accept: text/event-stream"
is essential for establishing a streaming connection, signaling to the server that the client can process streaming data as it becomes available.
When requesting streaming data, the server keeps the connection open, sending real-time updates as AI nodes process them. Each data packet contains a portion of the AI's response, allowing the client to process or display the information incrementally.
Last updated