Get the current code of a smart contract
(scid string)
| 2048 | |
| 2049 | // Get the current code of a smart contract |
| 2050 | func getContractCode(scid string) (code string, err error) { |
| 2051 | var params = rpc.GetSC_Params{SCID: scid, Variables: false, Code: true} |
| 2052 | var result rpc.GetSC_Result |
| 2053 | |
| 2054 | rpc_client.WS, _, err = websocket.DefaultDialer.Dial("ws://"+session.Daemon+"/ws", nil) |
| 2055 | if err != nil { |
| 2056 | return |
| 2057 | } |
| 2058 | |
| 2059 | input_output := rwc.New(rpc_client.WS) |
| 2060 | rpc_client.RPC = jrpc2.NewClient(channel.RawJSON(input_output, input_output), nil) |
| 2061 | |
| 2062 | err = rpc_client.RPC.CallResult(context.Background(), "DERO.GetSC", params, &result) |
| 2063 | if err != nil { |
| 2064 | logger.Errorf("[Engram] Error getting SC code: %s\n", err) |
| 2065 | return |
| 2066 | } |
| 2067 | |
| 2068 | code = result.Code |
| 2069 | |
| 2070 | return |
| 2071 | } |
| 2072 | |
| 2073 | // DVM starter InitializePrivate() example for smart contract builder |
| 2074 | func dvmInitFuncExample() string { |
no outgoing calls
no test coverage detected