Getting Started with FET Token for Agent development
This is currently a work in progress and may be subject to further updates and revisions.
Introduction
The FET token was created to facilitate payments in an Agentic ecosystem, these are micro payments to one another which traditional currencies do not support.
Acquiring FET Tokens
Exchanges are the simplest way to get FET tokens.
Visit a trusted exchange such as Coinbase or Binance. You may need to create an account, which will involve you passing KYC. Once your account is enabled, you can buy FET token. You can buy this with most global currencies, just check on the exchange which currencies they accept.
Mainnet or testnet
If you don’t want to use mainnet tokens, we support test environment transactions (testnet). This is really useful for developing agent before mainnet deployment.
By default, your agent will run in testnet, you’ll see that in the log output when you run an agent:
python client.py
INFO: [agent]: Starting agent with address: agent1qftyqsedg740hfyrjpf3nlm2saf3z02sra7dn64yqqc7jktlfpg8us8us23
INFO: [agent]: Starting server on http://0.0.0.0:8001 (Press CTRL+C to quit)
INFO: [uagents.registration]: Registration on Almanac API successful
WARNING: [uagents.registration]: I do not have enough funds to register on Almanac contract
INFO: [uagents.registration]: Adding testnet funds to fetch1aatyrgyv0dcjna072fdaadsx6sennxlws3gp4w
INFO: [uagents.registration]: Registration on Almanac API successful
INFO: [uagents.registration]: Registering on almanac contract...
INFO: [uagents.registration]: Registering on almanac contract...complete
When your agent starts it will try and register to the Almanac, if the agent has not funds to do so, they are given to the agent.
However, if you want your agent to be part of the mainnet, you must update your agent init to include network
:
agent = Agent(name="mainnet_agent",
seed="",
port=8001,
endpoint=["http://127.0.0.1:8001/submit"],
network="mainnet"
)
Your logs for an agent like the above would be:
python example.py
INFO: [example]: Starting agent with address: agent1qftyqsedg740hfyrjpf3nlm2saf3z02sra7dn64yqqc7jktlfpg8us8us23
INFO: [example]: Starting server on http://0.0.0.0:8001 (Press CTRL+C to quit)
INFO: [uagents.registration]: Registration on Almanac API successful
WARNING: [uagents.registration]: I do not have enough funds to register on Almanac contract
INFO: [uagents.registration]: Send funds to wallet address: fetch1aatyrgyv0dcjna072fdaadsx6sennxlws3gp4w
WARNING: [uagents.registration]: Failed to register on Almanac contract due to insufficient funds
To give your agent tokens checkout How to transfer tokens to your Agents.
Storing FET
Ideally you would be sending this FET to your agent to transact on the network. However, if you’d like greatersecurity or accessibility.
For short-term storage goals, the ASI Wallet is an excellent choice; it provides direct functionalities for daily activities such as staking and interacting with Agents.
For long-term storage goals, you can enhance security by integrating your ASI Wallet with a hardware wallet like Ledger, offering robust protection for your assets. Follow this guide here if you wish to set up the ASI Alliance extension wallet with a Ledger hardware wallet.
How to transfer tokens to your Agents
You can download and use the uAgents library to create autonomous Agents capable of interacting with other Agents in a decentralized environment. Check out this guide here to get started with Agents development.
In order to get your Agent up and running within the Fetch.ai ecosystem, you will need to retrieve the Agent’s address and fund it with FET tokens to make it correctly register within the network.
When creating your account, it is crucial to securely store your seed phrase. The seed phrase is essential for accessing your Agent’s identity and controlling any funds it holds. Treat it with the highest level of security to prevent unauthorized access!
Getting your Agent address to send tokens to your Agent
The following Python script demonstrates how to create and initialize an Agent using the uagents
and cosmpy
libraries, to connect it to the Fetch.ai Mainnet, and retrieve its address and balance information:
from uagents import Agent, Context
import cosmpy
from cosmpy.aerial.client import LedgerClient, NetworkConfig
agent = Agent(name="alice", seed="", port=8000, test=False, endpoint=["http://localhost:8000/submit"])
@agent.on_event("startup")
async def introduce_agent(ctx: Context):
ctx.logger.info(f"ASI network address:{agent.wallet.address()}")
ledger_client = LedgerClient(NetworkConfig.fetch_mainnet())
address: str = agent.wallet.address()
balances = ledger_client.query_bank_all_balances(address)
ctx.logger.info(f"Balance of addr: {balances}")
if __name__ == "__main__":
agent.run()
You must update the seed value, and store it safely. Losing this value will lose you your tokens.
In the code example above an Agent named alice
is initialized with a specified name
, port
, endpoint
, and seed
parameters. When the Agent starts up, it logs the wallet address and queries the balance using the LedgerClient
connected to the Fetch.ai Mainnet. Finally, the script runs the Agent, which processes the startup
event and retrieves the balance, allowing the Agent to interact with the Fetch.ai network.
Once you run the above Agent script, you will see your Agent address and balance printed out. You will see something similar to the following output:
INFO: [alice]: Registration on Almanac API successful
INFO: [alice]: Registering on almanac contract...
INFO: [alice]: Registering on almanac contract...complete
INFO: [alice]: Agent inspector available at https://agentverse.ai/inspect/?uri=http%3A//127.0.0.1%3A8000&address=agent1qdxdrwqek4pt9xt8kggcxus0zm54d4vgdznrs6y5acn26paphervwfj7pdd
INFO: [alice]: Starting server on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: [alice]: ASI network address:fetch1ujr7wyuvza7uwnkr3usv53hjlwjvu8s7l06vzf
INFO: [alice]: Balance of addr: []
You can now use this address to transfer your purchased FET tokens from the exchange to this Agent’s address. This
should be as simple as withdrawing native FET, by selecting the Fetch.ai Mainnet network when withdrawing. Some
exchanges do not support Native FET, and you will need to use the token bridge,
luckily we have a guide for that too
.