我正在嘗試在 Hedera 上部署合約;該文件是 9766 字節(jié),所以我創(chuàng)建了一個文件并將合同附加到它,但現(xiàn)在我收到錯誤“異常收據(jù)狀態(tài):ERROR_DECODING_BYTESTRING:檢索合同創(chuàng)建記錄時出錯”。我相信我的代碼做錯了什么。任何幫助將不勝感激。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 回答

不負(fù)相思意
TA貢獻(xiàn)1777條經(jīng)驗 獲得超10個贊
我想我在 Discord 中對此做出了回應(yīng),但這里是為了完成。我認(rèn)為問題在于您的代碼Bin
在bin
.
轉(zhuǎn)變 smartContractByteCode := smartContract.Contracts["contract.sol:ScanInput"].Bin
為了
smartContractByteCode := smartContract.Contracts["contract.sol:ScanInput"].bin
- 1 回答
- 0 關(guān)注
- 135 瀏覽
添加回答
舉報
0/150
提交
取消