Giter Site home page Giter Site logo

Comments (6)

albertoramires avatar albertoramires commented on August 16, 2024 1

@ayrat555 is there a way to do something similar to @somoza's example with the ethereumex library? Using a PK instead of accounts that is.

from ethereumex.

ayrat555 avatar ayrat555 commented on August 16, 2024

can you please print and share here

%{
      data: "0x" <> abi_encoded_data,
      to: contract_address,
      from: address,
      gas: "0xc350",
      gasPrice: nil
    }

from ethereumex.

somoza avatar somoza commented on August 16, 2024

Hey Ayrat!

I noticed that I have to sign it with the from address' private key. I used the ETH dep for that, here is my working code:

abi_encoded_data  = ABI.encode("setTest(uint,string)", [1, "Foo"]) |> Base.encode16(case: :lower)
contract_address  = Application.get_env(:ethereumex, :contract_address)
account1_private_key = "5b17b72f21c486a469fb9a5f601bf53060c933a010cfc9d1900c069f536cd220"
account1_address =  Application.get_env(:ethereumex, :owner)

{:ok, tx_hash} = ETH.send_transaction(%{
  to: contract_address,
  from: account1_address,
  gas: "0xc350",
  gasPrice: nil,
  data: "0x" <> abi_encoded_data,
}, account1_private_key) #Signed as is a status modifier.

I can't manage this in a single way using Ethereumix...

I hope this could help somebody, even if is not the most common use to manage send transactions from the backend. I realize that people prefer to pass this task to JS on frontend in order to allow clients to use their wallets through metamask.

PS: Don't worry about the private key, it's a local Ganache environment.

from ethereumex.

ayrat555 avatar ayrat555 commented on August 16, 2024

@somoza hello can you please update README 🙏

from ethereumex.

somoza avatar somoza commented on August 16, 2024

I could and would be a pleasure indeed, but I'm not using Ethereum library but a third party. Is it not a problem to update the README?

from ethereumex.

ayrat555 avatar ayrat555 commented on August 16, 2024

@somoza thank you anyway!

from ethereumex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.