Junaidb commited on
Commit
86d64b7
·
verified ·
1 Parent(s): 0618528

Update components/agentcreation.py

Browse files
Files changed (1) hide show
  1. components/agentcreation.py +5 -1
components/agentcreation.py CHANGED
@@ -14,17 +14,21 @@ rpc=AsyncClient("https://mainnet.helius-rpc.com/?api-key=4e833ada-d32c-48c5-b020
14
 
15
  async def create_keypair(agent):
16
  """Create a new keypair and return it as MongoDB-friendly format"""
 
 
17
  keypair = Keypair()
18
  keypair_data = {
19
  "agent_id": agent,
20
  "public_key": str(keypair.pubkey()),
21
  "secret_key": bytes(keypair).hex()
22
  }
23
- await coll.update_one(
24
  {"owner": "system"},
25
  {"$push": {"agents": keypair_data}}
26
  )
27
  print(res)
 
 
28
 
29
 
30
  async def transfer_sol(from_keypair, to_pubkey, amount_sol):
 
14
 
15
  async def create_keypair(agent):
16
  """Create a new keypair and return it as MongoDB-friendly format"""
17
+
18
+ try:
19
  keypair = Keypair()
20
  keypair_data = {
21
  "agent_id": agent,
22
  "public_key": str(keypair.pubkey()),
23
  "secret_key": bytes(keypair).hex()
24
  }
25
+ res=await coll.update_one(
26
  {"owner": "system"},
27
  {"$push": {"agents": keypair_data}}
28
  )
29
  print(res)
30
+ except Exception as e:
31
+ print(e)
32
 
33
 
34
  async def transfer_sol(from_keypair, to_pubkey, amount_sol):