@@ -6,12 +6,13 @@ import {
6
6
State ,
7
7
elizaLogger ,
8
8
} from "@ai16z/eliza" ;
9
+ import fs from "fs" ;
9
10
import { DeployContractParams } from "../types" ;
10
11
import { ClientProvider } from "../providers/client" ;
11
12
import { getParamsWithLLM } from "../utils/llm" ;
12
13
13
14
const deployContractTemplate = `
14
- # Task: Determine the contract code and constructor arguments for deploying a contract.
15
+ # Task: Determine the contract code file path and constructor arguments for deploying a contract.
15
16
16
17
# Instructions: The user is requesting to deploy a contract to the GenLayer protocol.
17
18
@@ -21,7 +22,7 @@ Here is the user's request:
21
22
# Your response must be formatted as a JSON block with this structure:
22
23
\`\`\`json
23
24
{
24
- "code ": "<Contract Code>",
25
+ "code_file ": "<Contract Code File Path >",
25
26
"args": [<Constructor Args>],
26
27
"leaderOnly": <true/false>
27
28
}
@@ -61,21 +62,23 @@ export const deployContractAction: Action = {
61
62
elizaLogger . debug ( "Parsed parameters:" , options ) ;
62
63
elizaLogger . info (
63
64
"Deploying contract with code length:" ,
64
- options . code . length
65
+ options . code_file . length
65
66
) ;
66
67
68
+ const code = await fs . readFileSync ( options . code_file , "utf8" ) ;
69
+
67
70
const result = await clientProvider . client . deployContract ( {
68
- code : options . code ,
71
+ code : code ,
69
72
args : options . args ,
70
73
leaderOnly : options . leaderOnly ,
71
74
} ) ;
72
75
73
76
elizaLogger . success (
74
- `Successfully deployed contract at address : ${ result } `
77
+ `Successfully sent contract for deployment. Transaction hash : ${ result } `
75
78
) ;
76
79
await callback (
77
80
{
78
- text : `Successfully deployed contract at address : ${ result } ` ,
81
+ text : `Successfully sent contract for deployment. Transaction hash : ${ result } ` ,
79
82
} ,
80
83
[ ]
81
84
) ;
0 commit comments