public static Tuple <string, string> TransData(string contractabi, string contractAddress, string funcName, object[] args, BigInteger groupId, BigInteger blockLimit, byte[] extraData, bool smcrypto, ECKeyPair key) { try { if (string.IsNullOrEmpty(funcName)) { return(new Tuple <string, string>("", "contract not has function")); } Nethereum.ABI.JsonDeserialisation.ABIDeserialiser abijson = new Nethereum.ABI.JsonDeserialisation.ABIDeserialiser(); var abi = abijson.DeserialiseContract(contractabi); var funcData = Pack(abi, funcName, args, smcrypto); FunctionABI method = null; foreach (var item in abi.Functions) { if (item.Name == funcName) { method = item; } } if (method.Constant) { return(new Tuple <string, string>(Hex.ToHexString(funcData), "")); } var toAddress = Hex.Decode(contractAddress.Replace("0x", "")); var nonce = RandomHelper.GetRandomBytes(32); var tx = NewTransaction(nonce, toAddress, null, GAS_LIMIT, GAS_PRICE, blockLimit, funcData, ChainId, groupId, extraData, smcrypto); var dataByte = SignData(tx, key); return(new Tuple <string, string>(Hex.ToHexString(dataByte), string.Empty)); } catch (Exception ex) { throw ex; } }
public static ContractABI TransContract(string ContractAbi) { Nethereum.ABI.JsonDeserialisation.ABIDeserialiser json = new Nethereum.ABI.JsonDeserialisation.ABIDeserialiser(); var aa = json.DeserialiseContract(ContractAbi); return(aa); }
public static Tuple <string, string> TransData(string contractabi, string contractAddress, string funcName, object[] args, string channelId, ulong blockLimit, uint version, ulong quota, bool smcrypto, ECKeyPair key) { try { if (string.IsNullOrEmpty(funcName)) { return(new Tuple <string, string>("", "contract not has function")); } Nethereum.ABI.JsonDeserialisation.ABIDeserialiser abijson = new Nethereum.ABI.JsonDeserialisation.ABIDeserialiser(); var abi = abijson.DeserialiseContract(contractabi); var funcData = Pack(abi, funcName, args, false); FunctionABI method = null; foreach (var item in abi.Functions) { if (item.Name == funcName) { method = item; } } if (method.Constant) { return(new Tuple <string, string>(Hex.ToHexString(funcData), "")); } var nonce = RandomHelper.GetRandomNonce(32); var tx = NewTransaction(nonce, contractAddress, quota, version, blockLimit, funcData, channelId); Console.WriteLine(string.Format("tx:{0}", Hex.ToHexString(Util.Marshal(tx).ToByteArray()))); var dataByte = SignData(tx, smcrypto, key); var trans = new UnverifiedTransaction() { Transaction = tx, Signature = Util.ConvertToByteString(dataByte), Crypto = CitaCrypto.Default }; return(new Tuple <string, string>(Hex.ToHexString(Util.Marshal(trans).ToByteArray()), string.Empty)); } catch (Exception ex) { throw ex; } }