static async Task PerformContractTransactions(LocalTestNet localTestNet, EntryPointContract entryContract, SolcBytecodeInfo contractBytecode, Abi entryFunction) { // Perform the contract deployment transaction var deployParams = new TransactionParams { From = localTestNet.Accounts[0], Gas = ArbitraryDefaults.DEFAULT_GAS_LIMIT, GasPrice = ArbitraryDefaults.DEFAULT_GAS_PRICE }; var contractAddress = await ContractFactory.Deploy(localTestNet.RpcClient, HexUtil.HexToBytes(contractBytecode.Bytecode), deployParams); var contractInstance = new ContractInstance( entryContract.ContractPath, entryContract.ContractName, localTestNet.RpcClient, contractAddress, localTestNet.Accounts[0]); // If entry function is specified then send transasction to it. if (entryFunction != null) { var callData = EncoderUtil.GetFunctionCallBytes($"{entryFunction.Name}()"); var ethFunc = EthFunc.Create(contractInstance, callData); var funcTxParams = new TransactionParams { From = localTestNet.Accounts[0], Gas = ArbitraryDefaults.DEFAULT_GAS_LIMIT, GasPrice = ArbitraryDefaults.DEFAULT_GAS_PRICE }; await ethFunc.SendTransaction(funcTxParams); } }
public void FunctionDataDecode_MixedParamTypes() { var encoded = "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000100ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd4920000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff00000000000000000000000000000000000000000000000000000000000000096d7920737472696e670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000098e4625b2d7424c403b46366150ab28df406340800000000000000000000000040515114eea1497d753659dff85910f838c6b234000000000000000000000000df0270a6bff43e7a3fd92372dfb549292d683d22"; var ethFunc = EthFunc.Create <bool, string, long, Address[], byte, ulong[]>( null, null, "bool", DecoderFactory.Decode, "string", DecoderFactory.Decode, "int56", DecoderFactory.Decode, "address[]", DecoderFactory.GetArrayDecoder(EncoderFactory.LoadEncoder("address", default(Address))), "uint8", DecoderFactory.Decode, "uint64[3]", DecoderFactory.GetArrayDecoder(EncoderFactory.LoadEncoder("uint64", default(ulong)))); var p1 = true; var p2 = "my string"; var p3 = (long)-11118; var p4 = new Address[] { "0x98E4625b2d7424C403B46366150AB28Df4063408", "0x40515114eEa1497D753659DFF85910F838c6B234", "0xDf0270A6BFf43e7A3Fd92372DfB549292D683D22" }; var p5 = (byte)99; var p6 = new ulong[] { 9, 0, ulong.MaxValue }; var(r1, r2, r3, r4, r5, r6) = ethFunc.ParseReturnData(encoded.HexToBytes()); Assert.Equal(p1, r1); Assert.Equal(p2, r2); Assert.Equal(p3, r3); Assert.Equal(p4, r4); Assert.Equal(p5, r5); Assert.Equal(p6, r6); }