by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 28 09:26

    juanfranblanco on master

    Eip712TypedDataSigner type added Build fix for .netstandard Eip712TypedDataSignerTest tests… and 3 more (compare)

  • Apr 13 09:50

    juanfranblanco on master

    Update README.md (compare)

  • Feb 25 13:10

    juanfranblanco on master

    Adding samples for CID, Multifo… Merge branch 'master' of https:… (compare)

  • Feb 14 05:29

    juanfranblanco on master

    Update README.md (compare)

  • Feb 13 22:57

    juanfranblanco on master

    Update README.md (compare)

  • Feb 13 17:41

    juanfranblanco on master

    Forcing null to allow mono wasm (compare)

  • Feb 13 13:04

    juanfranblanco on 3.7.0

    (compare)

  • Feb 12 18:31

    juanfranblanco on master

    Update Erc20TokenTester.cs (compare)

  • Feb 12 17:39

    juanfranblanco on master

    Removing not required test (compare)

  • Feb 12 16:02

    juanfranblanco on master

    Upgrading parity (compare)

  • Feb 12 15:46

    juanfranblanco on master

    #617 Removing fixed sized of We… Making globally configurable th… Simplifying adding a subnode in… and 1 more (compare)

  • Feb 12 07:33

    juanfranblanco on master

    ENS upgrade and extra services … Adding abi / bin of corrent con… Merge branch 'master' of https:… (compare)

  • Feb 04 15:01

    juanfranblanco on master

    Issue: #619 - Parameter Decodin… Merge pull request #620 from Da… (compare)

  • Jan 29 11:29

    juanfranblanco on master

    Typo on FunctionOutput created … 3.6.2 for autogen (compare)

  • Jan 29 10:56

    juanfranblanco on master

    Transaction Factory Create from… (compare)

  • Jan 28 06:21

    juanfranblanco on master

    #618 creating an empty construc… (compare)

  • Jan 27 14:37

    juanfranblanco on 3.6.0

    (compare)

  • Jan 24 16:52

    juanfranblanco on master

    Ignore old block to retrieve er… (compare)

  • Jan 24 13:08

    juanfranblanco on master

    Moving up a version 3.6 (compare)

  • Jan 24 11:35

    juanfranblanco on master

    Estimation check revert message (compare)

Juan Blanco
@juanfranblanco
Gas price gives you the current average, you can increase it if you want to a higher value.
@sudhirtibrewal ^^ another option (if you don't trust the node ) is to calculate the average over previous blocks or check pending transactions
Juan Blanco
@juanfranblanco
Also please check the examples on how to interact with the chain.. I'll post later a simpler example.
But quick question. What does txnData contain? Is that from a smart contract data? You should not need to use a ManagedAccount you can simply use an Account with a private key and use Web3.TransactionManager.Send..
You can provide a transaction input there and txn will be signed for you.
sudhirtibrewal
@sudhirtibrewal
It is not smart contract data
Juan Blanco
@juanfranblanco
ah ok so you are just sending a txn with some data
Juan Blanco
@juanfranblanco
@sudhirtibrewal hopefully this full example helps
using System;
using System.Text;
using Nethereum.Hex.HexConvertors.Extensions;
using System.Threading.Tasks;
using Nethereum.Web3;
using Nethereum.Web3.Accounts;
using Nethereum.Hex.HexConvertors.Extensions;
using Nethereum.RPC.TransactionManagers;
using Nethereum.Signer;
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Util;
using Nethereum.Hex.HexTypes;

public class Program
{
    private static async Task Main(string[] args)
    {
        //First let's create an account with our private key for the account address 
        var privateKey = "0x7580e7fb49df1c861f0050fae31c2224c6aba908e116b8da44ee8cd927b990b0";
        var account = new Account(privateKey);

        Console.WriteLine("Our account: " + account.Address);
        //Now let's create an instance of Web3 using our account pointing to our nethereum testchain
        var web3 = new Web3(account, "http://testchain.nethereum.com:8545");

        var toAddress = "0x1bb31d596c34bd81e1f0be1edf3840a7b43dd9cd";
        var transactionManager = web3.TransactionManager;

                //Gas price and nonce is calculated by the transaction manager so no need to set it
                var txnInput = new TransactionInput() {
                    From = account.Address,
                    To = toAddress,
                    Data = "0x7b227465737444617465223a2232372f30352f323032302031333a32353a35322e38373120504d227d"
            };

                Console.WriteLine(transactionManager.DefaultGas);
                //lets estimate and set the gas as we have some data
                var gasEstimate = await  transactionManager.EstimateGasAsync(txnInput);
                txnInput.Gas = gasEstimate;

                var txnHash1 = await transactionManager.SendTransactionAsync(txnInput);

                Console.WriteLine(txnHash1);

                var txnInput2 = new TransactionInput() {
                    From = account.Address,
                    To = toAddress,
                    Data = "0x7b227465737444617465223a2232372f30352f323032302031333a32353a35322e38373120504d227d",
                    Gas = gasEstimate,
                    //Lets use the same nonce to replace the transaction
                    Nonce = txnInput.Nonce
            };

                //Lets increment the gas price to replace the transaction
                var gasPrice = await web3.Eth.GasPrice.SendRequestAsync();
                //incrementing the gas price
                txnInput2.GasPrice = new HexBigInteger(gasPrice.Value + Web3.Convert.ToWei(1, UnitConversion.EthUnit.Gwei));

                var txnHash2 = await transactionManager.SendTransactionAsync(txnInput2);

                Console.WriteLine(txnHash2);

        }
}
you can copy and paste it and run it in the http://playground.nethereum.com
as you can see you don't need to use the offline transaction method
this is already handled by the TransactionManager.. it is mainly the same but the TransactionManager handles for you if you don't want to set the nonce, gas price or even the total gas if you just send ether
the demo demonstrates how to speed up your transaction my increasing the gas price
sudhirtibrewal
@sudhirtibrewal
thanks @juanfranblanco
sagarchaurasia260395
@sagarchaurasia260395
@juanfranblanco THis "error CS0518: Predefined type 'System.Object' is not defined or imported" error is coming while running inbuilt program in nethereum playground ? is playground working fine ?
Juan Blanco
@juanfranblanco
@sagarchaurasia260395 what example are you trying to run
sagarchaurasia260395
@sagarchaurasia260395
@juanfranblanco this one => "http://playground.nethereum.com/csharp/id/1003"
denisisack
@denisisack
Need help have been trying to verify signature generated offline by generating hash and signature then use verify method on solidity to verify the origin address if they match but it doesn't return exactly address
var sha3 = new Sha3Keccack();
var output = sha3.CalculateHashFromHex(userAccount.Address, id, "0");
signature1 = signer.EncodeUTF8AndSign(output, new EthECKey(privKey));
var addressRec2 = signer.EncodeUTF8AndEcRecover(output, signature1);
On local machine the results are okay but when send the same request to solidity the address that is returned on EcRecover is different from the sender address

pragma solidity ^0.5.0;
contract VerifySig {
function splitSignature(bytes memory sig)
public
pure
returns (uint8, bytes32, bytes32)
{
require(sig.length == 65);

   bytes32 r;
   bytes32 s;
   uint8 v;

   assembly {
       // first 32 bytes, after the length prefix
       r := mload(add(sig, 32))
       // second 32 bytes
       s := mload(add(sig, 64))
       // final byte (first byte of the next 32 bytes)
       v := byte(0, mload(add(sig, 96)))
   }

   return (v, r, s);

}
}

denisisack
@denisisack
They return address but it's not the same as signing address

pragma solidity ^0.5.12;

library ECVerify {
function ecrecovery(bytes32 hash, bytes memory sig) public pure returns (address) {
bytes32 r;
bytes32 s;
uint8 v;

if (sig.length != 65) {
   return (address(0));
}

assembly {
  r := mload(add(sig, 32))
  s := mload(add(sig, 64))
  v := and(mload(add(sig, 65)), 255)
}

// https://github.com/ethereum/go-ethereum/issues/2053
if (v < 27) {
  v += 27;
}

if (v != 27 && v != 28) {
   return (address(0));
}

return ecrecover(hash, v, r, s);

}

function ecverify(bytes32 hash, bytes memory sig, address signer) public view returns (bool) {
return signer == ecrecovery(hash, sig);
}
}

All they return results that are not consistent to the signing address
Juan Blanco
@juanfranblanco
@denisisack what signer are you using?
EthereumSigner ?
if it is prefixed
denisisack
@denisisack
Yes
Thanks
Ayush Gupta
@ayushgupta0610

Hey @juanfranblanco , while trying to unlock an account, we are getting the issue as

Argument 1: cannot convert from 'string' to 'Nethereum.RPC.Eth.EthCoinBase'

This is where we're facing the issue: await web3.Personal.UnlockAccount.SendRequestAsync(account,"Password","0x120000");

Juan Blanco
@juanfranblanco
also it es preferred to use a ManagedAccount with Web3 which uses underneath https://geth.ethereum.org/docs/rpc/ns-personal#personal_sendtransaction as it is much safer than maintaining your account unlocked all the time
Ayush Gupta
@ayushgupta0610
Oh is it? Thanks Juan, will look into it and implement ManagedAccount only then.
denisisack
@denisisack
@juanfranblanco Thanks
sagarchaurasia260395
@sagarchaurasia260395
@juanfranblanco , where i can define network (RPC) , if using managed accounts => var senderAddress = "0x12890d2cce102216644c59daE5baed380d84830c";
var password = "password";
var account = new ManagedAccount(senderAddress, password);
var web3 = new Nethereum.Web3.Web3(account);
Juan Blanco
@juanfranblanco
It is the next parameter
Web3(account,URL)
sagarchaurasia260395
@sagarchaurasia260395
Thanks @juanfranblanco !
Ayush Gupta
@ayushgupta0610
using System;
using System.Text;
using Nethereum.Hex.HexConvertors.Extensions;
using System.Threading.Tasks;
using Nethereum.Web3;
using Nethereum.Web3.Accounts;
using Nethereum.Web3.Accounts.Managed;
using Nethereum.Hex.HexConvertors;
using Nethereum.Hex.HexTypes;
using Nethereum.ABI.FunctionEncoding.Attributes;
using Nethereum.Contracts.CQS;
using Nethereum.Util;
using Nethereum.Hex.HexConvertors.Extensions;
using Nethereum.Contracts;
using Nethereum.Contracts.Extensions;
using System.Numerics;

public class Program
{

 static async Task Main(string[] args)
 {
     var abi = @"<Contract ABI>";
     var contractAddress = "0xE95191E604C7E5E3f5bF8FC6D086D6b114d84ED4";

    var senderAddress = "0x12890d2cce102216644c59daE5baed380d84830c";
    var password = "password";
    var account = new ManagedAccount(senderAddress, password);
    var web3 = new Nethereum.Web3.Web3(account, "http://localhost:8545");

    var contractHandler = web3.Eth.GetContractTransactionHandler<set>(abi,contractAddress);
    var Set = new set()
    {
   _x = 100
    };
    var transactionReceipt2 = await contractHandler.SendRequestAndWaitForReceiptAsync(contractAddress, Set);
    var transactionHash = transactionReceipt2.TransactionHash;
 }

}
And here's the error I'm getting:
(76,18): error CS0012: The type 'IClient' is defined in an assembly that is not referenced. You must add a reference to assembly 'Nethereum.JsonRpc.Client, Version=3.7.0.0, Culture=neutral, PublicKeyToken=8768a594786aba4e'.
(78,64): error CS0246: The type or namespace name 'set' could not be found (are you missing a using directive or an assembly reference?)
(78,34): error CS1501: No overload for method 'GetContractTransactionHandler' takes 2 arguments
Not really able to wrap my head around ManagedAccount (https://docs.nethereum.com/en/latest/Nethereum.Workbooks/docs/nethereum-managed-accounts.workbook/). Can someone help me out with a detailed eg?
Ayush Gupta
@ayushgupta0610
Here's the contract code:
pragma solidity ^0.5.13;
contract Test {

    uint256 public x;

    function set(uint256 _x) public {
        x = _x;
    }

    function get() public view returns (uint256 retX) {
        return x;
    }

}
Ayush Gupta
@ayushgupta0610
@juanfranblanco I couldn't follow the ManagedAccount (https://docs.nethereum.com/en/latest/Nethereum.Workbooks/docs/nethereum-managed-accounts.workbook/) doc. Could you help me with a detailed eg.?
Juan Blanco
@juanfranblanco
@ayushgupta0610 What IDE are you using? Are you using the code generator?
Juan Blanco
@juanfranblanco
Apologies I forgot to link to this document http://docs.nethereum.com/en/latest/nethereum-codegen-vscode-demo/
Also what is your use case ? Why are you using Managed Account Vs an Account with its private key?