我正在尝试在 Hedera 上部署合约;该文件是 9766 字节,所以我创建了一个文件并将合同附加到它,但现在我收到错误“异常收据状态:ERROR_DECODING_BYTESTRING:检索合同创建记录时出错”。我相信我的代码做错了什么。任何帮助将不胜感激。package blockchainimport ( "encoding/json" "fmt" "io/ioutil" "github.com/.../scanner/env" "github.com/hashgraph/hedera-sdk-go/v2")type contract struct { Abi string `json:"abi"` Bin string `json:"bin"`}type contracts struct { Contracts map[string]contract `json:"contracts"` Version string `json:"version"`}func DeployContract() { var client *hedera.Client var err error // Retrieving network type from environment variable HEDERA_NETWORK client, err = hedera.ClientForName(env.GetEnv["HEDERA_NETWORK"]) if err != nil { println(err.Error(), ": error creating client") return } // Retrieving operator ID from environment variable OPERATOR_ID operatorAccountID, err := hedera.AccountIDFromString(env.GetEnv["OPERATOR_ID"]) if err != nil { println(err.Error(), ": error converting string to AccountID") return } // Retrieving operator key from environment variable OPERATOR_KEY operatorKey, err := hedera.PrivateKeyFromString(env.GetEnv["OPERATOR_KEY"]) if err != nil { println(err.Error(), ": error converting string to PrivateKey") return } // Setting the client operator ID and key client.SetOperator(operatorAccountID, operatorKey) // Make sure to close client after running defer func() { err = client.Close() if err != nil { println(err.Error(), ": error closing client") return } }() // Read in the compiled contract from contract.json rawSmartContract, err := ioutil.ReadFile("./contract/contract.json") if err != nil { println(err.Error(), ": error reading contract.json") return }
1 回答
不负相思意
TA贡献1777条经验 获得超10个赞
我想我在 Discord 中对此做出了回应,但这里是为了完成。我认为问题在于您的代码Bin
在bin
.
转变 smartContractByteCode := smartContract.Contracts["contract.sol:ScanInput"].Bin
为了
smartContractByteCode := smartContract.Contracts["contract.sol:ScanInput"].bin
- 1 回答
- 0 关注
- 115 浏览
添加回答
举报
0/150
提交
取消