protected virtual void InitialiseInnerServices() { Eth = new EthApiContractService(Client); Shh = new ShhApiService(Client); Net = new NetApiService(Client); Personal = new PersonalApiService(Client); }
public ContractHandler(string contractAddress, EthApiContractService ethApiContractService, string addressFrom = null) { ContractAddress = contractAddress; EthApiContractService = ethApiContractService; AddressFrom = addressFrom; }
public void ShouldDecodeMultipleParamsIncludingArray() { var abi = @"[{""constant"":false,""inputs"":[{""name"":""a"",""type"":""uint256""},{""name"":""b"",""type"":""string""},{""name"":""c"",""type"":""uint[3]""} ],""name"":""test"",""outputs"":[{""name"":""d"",""type"":""uint256""}],""type"":""function""}]"; var ethApi = new EthApiContractService(null, null); var contract = ethApi.GetContract(abi, "ContractAddress"); //get the function by name var testFunction = contract.GetFunction("test"); var array = new[] { 1, 2, 3 }; var str = "hello"; var data = testFunction.GetData(69, str, array); var decode = testFunction.DecodeInput(data); Assert.Equal(69, (BigInteger)decode[0].Result); Assert.Equal(str, (string)decode[1].Result); var listObjects = decode[2].Result as List <object>; if (listObjects != null) { //System.Array.ConvertAll(listObjects.ToArray(), x => (int)((BigInteger)x)); var newArray = listObjects.Select(x => (int)(BigInteger)x).ToArray(); Assert.Equal(array, newArray); } }
protected virtual void InitialiseInnerServices() { Eth = new EthApiContractService(Client); Shh = new ShhApiService(Client); Net = new NetApiService(Client); Personal = new PersonalApiService(Client); Convert = new UnitConversion(); sha3Keccack = new Sha3Keccack(); OfflineTransactionSigner = new TransactionSigner(); addressUtil = new AddressUtil(); }
/// <summary> /// Returns a <see cref="Contract"/> instance for one of the known cryptokitty contracts. /// </summary> /// <param name="instance">The <see cref="EthApiContractService"/> being extended.</param> /// <param name="contract">A <see cref="CryptoKittyContractType"/> identifying the desired contract.</param> /// <returns>A <see cref="Contract"/> instance.</returns> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="contract"/> is not a recognized value.</exception> /// <exception cref="InvalidOperationException">Thrown if there is some failure attaching to a valid contract.</exception> public static Contract GetKittyContract(this EthApiContractService instance, CryptoKittyContractType contract) { // Note that ForContract will throw on an invalid contract type var address = Globals.Contracts.Address.ForContract(contract); // If we made it this far then we know we were givven a good contract var ret = instance.GetContract(Globals.Contracts.ABI.ForContract(contract), address); if (ret == null) { throw new InvalidOperationException(Res.FatalContractFailure); } return(ret); }
public void ShouldDecodeInt() { var abi = @"[{""constant"":false,""inputs"":[{""name"":""a"",""type"":""uint256""}],""name"":""multiply"",""outputs"":[{""name"":""d"",""type"":""uint256""}],""type"":""function""}]"; var ethApi = new EthApiContractService(null); var contract = ethApi.GetContract(abi, "ContractAddress"); //get the function by name var multiplyFunction = contract.GetFunction("multiply"); var data = multiplyFunction.GetData(69); var decode = multiplyFunction.DecodeInput(data); Assert.Equal(69, (BigInteger)decode[0].Result); }
public void Initialise(EthApiContractService ethApiContractService) { Eth = ethApiContractService; }
public void Initialise(IClient client, ITransactionManager transactionManager) { Eth = new EthApiContractService(client, transactionManager); }
public void Initialise(IClient client, IAccount account) { Eth = new EthApiContractService(client, account.TransactionManager); }