github.com/0chain/gosdk@v1.17.11/wasmsdk/smartcontract.go (about) 1 package main 2 3 import ( 4 "encoding/json" 5 6 "github.com/0chain/gosdk/core/transaction" 7 "github.com/0chain/gosdk/zboxcore/sdk" 8 "github.com/0chain/gosdk/zcncore" 9 ) 10 11 func faucet(methodName, input string, token float64) (*transaction.Transaction, error) { 12 return executeSmartContract(zcncore.FaucetSmartContractAddress, 13 methodName, input, zcncore.ConvertToValue(token)) 14 } 15 16 // executeSmartContract issue a smart contract transaction 17 // - address is the smart contract address 18 // - methodName is the method name to be called 19 // - input is the input data for the method 20 // - value is the value to be sent with the transaction 21 func executeSmartContract(address, methodName, input string, value uint64) (*transaction.Transaction, error) { 22 return sdk.ExecuteSmartContract(address, 23 transaction.SmartContractTxnData{ 24 Name: methodName, 25 InputArgs: json.RawMessage([]byte(input)), 26 }, value, 0) 27 }