// --- protected EthereumBaseClient(AppConfig appConfig, LogFactory logFactory) { Logger = logFactory.GetLoggerFor(this); AppConfig = appConfig; EthProvider = new Nethereum.JsonRpc.Client.RpcClient(new Uri(appConfig.Services.Ethereum.Provider)); //EthLogsProvider = new Nethereum.JsonRpc.Client.RpcClient(new Uri(appConfig.Services.Ethereum.LogsProvider)); Web3Utils = new Web3Utils(EthProvider); }
protected EthereumBaseClient(AppConfig appConfig, ILogger logFactory) { Logger = logFactory.GetLoggerFor(this); MntpContractAddress = appConfig.Services.Ethereum.MntpContractAddress; MntpContractAbi = appConfig.Services.Ethereum.MntpContractAbi; PoolContractAddress = appConfig.Services.Ethereum.PoolContractAddress; PoolContractAbi = appConfig.Services.Ethereum.PoolContractAbi; PoolFreezerContractAddress = appConfig.Services.Ethereum.PoolFreezerContractAddress; PoolFreezerContractAbi = appConfig.Services.Ethereum.PoolFreezerContractAbi; EthProvider = new Nethereum.JsonRpc.Client.RpcClient(new Uri(appConfig.Services.Ethereum.Provider)); EthLogsProvider = new Nethereum.JsonRpc.Client.RpcClient(new Uri(appConfig.Services.Ethereum.Provider)); }
public EthereumOracleConnector(string endpoint, string contractAddress, string pkcsUser, string key) { this.contractAddress = contractAddress; var client = new Nethereum.JsonRpc.Client.RpcClient(new Uri(endpoint)); account = new ExternalAccount("0x7957Db97cB19fB029968595E9325e2E5C92EAF33", new HSMExternalEthSigner(pkcsUser, key), 1); account.NonceService = new InMemoryNonceService("0x7957Db97cB19fB029968595E9325e2E5C92EAF33", client); account.InitialiseDefaultTransactionManager(client); web3 = new Web3Geth(account, endpoint); contract = web3.Eth.GetContract(abi, contractAddress); tokenDictionary.Add("USDT", "0xdac17f958d2ee523a2206206994597c13d831ec7"); tokenDictionary.Add("MTL", "0xF433089366899D83a9f26A773D59ec7eCF30355e"); tokenDictionary.Add("USDC", "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"); tokenDictionary.Add("BAT", "0x0d8775f648430679a709e98d2b0cb6250d2887ef"); tokenDictionary.Add("CRO", "0xa0b73e1ff0b80914ab6fe0444e65848c4c34450b"); tokenDictionary.Add("DEX", "0x497bAEF294c11a5f0f5Bea3f2AdB3073DB448B56"); tokenDictionary.Add("TUSD", "0x0000000000085d4780B73119b644AE5ecd22b376"); tokenDictionary.Add("DAI", "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"); tokenDictionary.Add("EGT", "0x8e1b448ec7adfc7fa35fc2e885678bd323176e34"); tokenDictionary.Add("ENJ", "0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c"); tokenDictionary.Add("HT", "0x6f259637dcd74c767781e37bc6133cd6a68aa161"); tokenDictionary.Add("INB", "0x17aa18a4b64a55abed7fa543f2ba4e91f2dce482"); tokenDictionary.Add("KCS", "0x039b5649a59967e3e936d7471f9c3700100ee1ab"); tokenDictionary.Add("ELF", "0xbf2179859fc6D5BEE9Bf9158632Dc51678a4100e"); tokenDictionary.Add("ZRX", "0xe41d2489571d322189246dafa5ebde1f4699f498"); tokenDictionary.Add("LINK", "0x514910771af9ca656af840dff83e8264ecf986ca"); tokenDictionary.Add("MANA", "0x0f5d2fb29fb7d3cfee444a200298f468908cc942"); tokenDictionary.Add("MATIC", "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0"); tokenDictionary.Add("MCO", "0xb63b606ac810a52cca15e44bb630fd42d8d1d83d"); tokenDictionary.Add("MKR", "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2"); tokenDictionary.Add("ZB", "0xbd0793332e9fb844a52a205a233ef27a5b34b927"); tokenDictionary.Add("OMG", "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07"); tokenDictionary.Add("PAX", "0x8e870d67f660d95d5be530380d0ec0bd388289e1"); tokenDictionary.Add("PERL", "0xb5a73f5fc8bbdbce59bfd01ca8d35062e0dad801"); tokenDictionary.Add("LAMB", "0x8971f9fd7196e5cee2c1032b50f656855af7dd26"); tokenDictionary.Add("SEELE", "0xb1eef147028e9f480dbc5ccaa3277d417d1b85f0"); tokenDictionary.Add("REP", "0x1985365e9f78359a9B6AD760e32412f4a445E862"); tokenDictionary.Add("REALT", "0x46cc7ec70746f4cbd56ce5fa9bb7d648398eaa5c"); tokenDictionary.Add("BRZ", "0x420412e765bfa6d85aaac94b4f7b708c89be2e2b"); tokenDictionary.Add("SNT", "0x744d70fdbe2ba4cf95131626614a1763df805b9e"); tokenDictionary.Add("NXPS", "0xa15c7ebe1f07caf6bff097d8a589fb8ac49ae5b3"); tokenDictionary.Add("GUSD", "0x056fd409e1d7a124bd7017459dfea2f387b6d5cd"); tokenDictionary.Add("BNB", "0xB8c77482e45F1F44dE1745F52C74426C631bDD52"); }
public async Task <(string, DateTime)> CriarTransacoesAsync(string hashDoArquivo, string assJwt) { var senderAddress = "0x3c30BdDA887BeE28e6D09F801E3f6B0E7AE876F6"; var client = new Nethereum.JsonRpc.Client.RpcClient(new Uri("https://ropsten.infura.io/v3/69d76e2ed4cf459091d6113d9f18b0c0")); var account = new Nethereum.Web3.Accounts.Account("5C634792510B7D93283FA4A03D6B396CEECE19E860BF0E0632C54BE513B10259"); var web3 = new Nethereum.Web3.Web3(account, client); var contractAddress = "0xF6676908F5E3580C7bFF689dF739D843607DBc6c"; var abi = @"[{'constant':false,'inputs':[{'name':'hashArquivo','type':'string'},{'name':'assinatura','type':'string'}],'name':'adicionarAssinatura','outputs':[],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[{'name':'hashArquivo','type':'string'}],'name':'removerAssinatura','outputs':[],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[],'name':'removeSdaContract','outputs':[],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':true,'inputs':[],'name':'empresa','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[{'name':'hashArquivo','type':'string'}],'name':'buscarAssinatura','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'inputs':[{'name':'_empresa','type':'string'}],'payable':false,'stateMutability':'nonpayable','type':'constructor'},{'anonymous':false,'inputs':[{'indexed':true,'name':'hashArquivo','type':'string'},{'indexed':true,'name':'assinatura','type':'string'},{'indexed':false,'name':'datahora','type':'uint256'}],'name':'AssinaturaAdicionada','type':'event'}]"; var contract = web3.Eth.GetContract(abi, contractAddress); var adicionarAssinaturaFunc = contract.GetFunction("adicionarAssinatura"); try { var trx = await adicionarAssinaturaFunc.SendTransactionAsync( senderAddress, new HexBigInteger(900000), new HexBigInteger(1000), new HexBigInteger(0), hashDoArquivo, assJwt); // Verificar se já foi processada Nethereum.RPC.Eth.DTOs.TransactionReceipt receiptAdd = null; while (receiptAdd == null) { receiptAdd = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(trx); System.Threading.Thread.Sleep(1000); } return(trx, DateTime.Now); } catch (Exception ex) { return(string.Empty, DateTime.Now); } }