Пример #1
0
        public async Task <string> CreateMintTransactionAsync(BigInteger nonce, string toAddress, BigInteger amount)
        {
            var call = new Mint
            {
                To       = toAddress,
                Amount   = amount,
                Nonce    = nonce,
                Gas      = 100000,
                GasPrice = 0
            };

            string transaction = await _mintHandler.SignTransactionAsync(_contractAddress, call);

            return(transaction);
        }
Пример #2
0
        public static async Task <string> TransferOfflineAsync(Web3 web3, string contractAddress, string recipient, BigInteger amount, HexBigInteger nonce, BigInteger gas, BigInteger gasPrice, string fromAddress = null)
        {
            IContractTransactionHandler <TransferFunction> transferHandler = web3.Eth.GetContractTransactionHandler <TransferFunction>();

            var transfer = new TransferFunction
            {
                To          = recipient,
                TokenAmount = amount,
                // Nethereum internally calls its Ethereum client by default to set the GasPrice, Nonce and estimate the Gas,
                // so if we want to sign the transaction for the contract completely offline we will need to set those values ourselves.
                Nonce    = nonce.Value,
                Gas      = gas,
                GasPrice = Web3.Convert.ToWei(gasPrice, UnitConversion.EthUnit.Gwei)
            };

            if (fromAddress != null)
            {
                transfer.FromAddress = fromAddress;
            }

            string result = await transferHandler.SignTransactionAsync(contractAddress, transfer).ConfigureAwait(false);

            return(result);
        }