Coder Social home page Coder Social logo

web3-eth's People

Contributors

aguestuser avatar alexmatskevich avatar astudnev avatar izetex avatar skryl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

web3-eth's Issues

NoMethodError: undefined method `compact' for #<Hash:0x000000014c5698>

Hello,
there is a problem when i try to use web3.contract(abi)
here is my code:
`abi = {"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_value","type":"uint256"}],"name":"burnFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"},{"name":"tokenName","type":"string"},{"name":"decimalUnits","type":"uint8"},{"name":"tokenSymbol","type":"string"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"}

myContract = web3.eth.contract(abi)`

here is the exception:

NoMethodError: undefined method compact' for #Hash:0x000000014fdbb0
from /var/lib/gems/2.3.0/gems/web3-eth-0.1.0/lib/web3/eth/rpc.rb:42:in block in request' from /usr/lib/ruby/2.3.0/net/http.rb:853:in start'
from /usr/lib/ruby/2.3.0/net/http.rb:584:in start' from /var/lib/gems/2.3.0/gems/web3-eth-0.1.0/lib/web3/eth/rpc.rb:39:in request'
from /var/lib/gems/2.3.0/gems/web3-eth-0.1.0/lib/web3/eth/ethereum.rb:37:in method_missing' from (irb):27 from /usr/bin/irb:11:in

'`

Thank you in advance

Calling non-constant function

When I run this:

        web3 = Web3::Eth::Rpc.new host: 'ropsten.infura.io/my_api_key', 
                                  port: 443,  
                                  connect_options: {
                                    open_timeout: 20,
                                    read_timeout: 140,
                                    use_ssl: true
                                  }
        # render html: web3.eth.blockNumber

        abi = [...myMethod...]
        contract = web3.eth.contract(abi)
        contractInstance = contract.at('...')
        
        result = contractInstance.myMethod(...)
        puts result

I get a RuntimeError (Function myMethod is not constant: myMethod, requires to sign transaction). How do you sign a method call transaction?

Sending a transaction

Is there a way to call a function (i.e. send a transaction) with this library?
If I wanted to programmatically call a function that updates blockchain state, what's the best way to do it?

RuntimeError: No method found in ABI: transfer

I'm try get data to send erc20 token to address ether and my code here

web3 = Web3::Eth::Rpc.new host: 'ropsten.infura.io', 
                                port: 443,  
                                connect_options: {
                                    open_timeout: 20,
                                    read_timeout: 140,
                                    use_ssl: true,
                                    rpc_path: '/xxxxxxxxxx'
                                }
ERC_ABI = [{.....}]
contractAddr = "0xFf............"
contract = web3.eth.contract(ERC_ABI).at(contractAddr)
data = contract.transfer.getData('0xg.......', 10000, {from: '0xc........'})

then get error

RuntimeError: No method found in ABI: transfer
        from (irb):24

pls help me, thanks all

undefined local variable or method `creates' for #<Web3::Eth::Transaction:0x...>

Environment

  • web3.version: 0.20.1
  • node: "Geth/v1.8.0-unstable-07d4a022/darwin-amd64/go1.9.3",
  • network: Mainnet(id: 1)

How to reproduce?

Using the example code

api = Web3::Eth::Etherscan.new 'Your API Key'
abi = api.contract_getabi address: '0x2ad180cbaffbc97237f572148fc1b283b68d8861'

myContract = web3.eth.contract(abi);
tx = web3.eth.getTransactionByHash '0x83da408b05061a2512fe1abf065b37a6aad9ae96d604b288a3da34bf9f1af9e6'
myContract.parse_call_args tx

What is the error?

myContract.parse_call_args tx call would produce the error

undefined local variable or method `creates' for #<Web3::Eth::Transaction:0x...>

Web3::Eth::Etherscan.new not working

I cannot use the Method Etherscan.new.

Traceback (most recent call last):
1: from (irb):1:in `

'
NameError (uninitialized constant Web3::Eth::Etherscan)

Please fix it.

Confusion about #events method

Hi @izetex @astudnev! ๐Ÿ‘‹๐Ÿป

First off, thank you so much for making this Ruby port of Web3. I was so happy to find a gem that works basically just like the Node/Python Web3 packages. It makes the prospect of doing ETH blockchain development way more appealing to me. ๐ŸŽ‰

As my first adventure into Web3 / Ethereum, I'm trying to port a small Node script that I inherited from an earlier person on the task.

This is the Node code that works.

// normal Web3 setup and connection
// โ€ฆ
const contract  = new web3.eth.Contract(abi, TOKEN_CONTRACT_ADDRESS);
const allEvents = yield contract.getPastEvents('Transfer', {
  fromBlock: FROM_BLOCK,
  toBlock: TO_BLOCK
});

Here's my current script.

require "json"
require "web3/eth"

FROM_BLOCK              = 4899001
TO_BLOCK                = 4900000
ETHEREUM_SERVER_HOST    = "[SCRUBBED FOR DEMONSTRATION]"
ETHERSCAN_API_KEY_TOKEN = "[SCRUBBED FOR DEMONSTRATION]"
ABI_ADDRESS             = "0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359"
TOKEN_CONTRACT_ADDRESS  = "0x99ea4db9ee77acd40b119bd1dc4e33e1c070b80d"

web3 = Web3::Eth::Rpc.new host: ETHEREUM_SERVER_HOST,
                          port: 8545,
                          connect_options: { read_timeout: 120 }

api      = Web3::Eth::Etherscan.new ETHERSCAN_API_KEY_TOKEN
abi      = api.contract_getabi address: ABI_ADDRESS
contract = web3.eth.contract(abi);
# Everything up to here works

# =========================== #

# I thought that I found what I was looking for in #events,
# but it only returns 4 events. I was expecting thousands.
# Maybe I don't understand where to get what I'm looking for.

puts contract.events.count
# => 4

# =========================== #

# This doesn't work
# No method found in ABI: getPastEvents (RuntimeError)
puts contract.getPastEvents('Transfer', { fromBlock: FROM_BLOCK, toBlock: TO_BLOCK })

I must be missing something, right?

Thanks again for this gem. I look forward to using it lots more. ๐Ÿ˜€

Getting Contract Instance

I am having some trouble trying to get a contract instance and call its methods from Rails. I am using truffle, web3-eth, and Rails 5.0+.

I deployed my contract to ropsten and got the abi. The abi looks like this:

abi = [
  {
    "constant": false,
    "inputs": [
      {
        "name": "_to",
        "type": "address"
      },
      {
        "name": "_tokenId",
        "type": "uint256"
      }
    ],
    "name": "approve",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  ...
]

I first tried using this like this:

    web3 = Web3::Eth::Rpc.new host: 'localhost',
                              port: 9545,
                              connect_options: {
                                use_ssl: false,
                                read_timeout: 120
                              }

    abi = [...]
    @contract = web3.eth.contract(abi);
    @contract_instance = @contract.at(CONTRACT_ADDRESS)

But I kept getting the exception RuntimeError: No method found in ABI.
So I looked at how a contract instance is initialized, I noticed you're expecting abi to be a single element rather than an array of objects.

Is there anything I'm misunderstanding?

Errno::ECONNREFUSED: Failed to open TCP connection to :80

api = Web3::Eth::Etherscan.new 'api_key',
                          connect_options: {
                            open_timeout: 10,
                            read_timeout: 70,
                            parse_result: true,
                            url: 'ropsten.etherscan.io/api'
                        }
api.contract_getabi '0xe3fedaecd47aa8eab6b23227b0ee56f092c967a9'

My code above and get error

Errno::ECONNREFUSED: Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80)
        from (irb):20

RuntimeError: Function transfer is not constant: transfer, requires to sign transaction

Hi, everyone
I am going to send transfer using ruby.
this is my code.
web3 = Web3::Eth::Rpc.new host: 'ropsten.infura.io',
port: 443,
connect_options: {
open_timeout: 20,
read_timeout: 140,
use_ssl: true,
rpc_path: '/xxxxxxxxxx'
}
ERC_ABI = '[{.....}]'
contractAddr = "0xFf............"
contract = web3.eth.contract(ERC_ABI).at(contractAddr)
data = contract.transfer.getData('0xg.......', 10000, {from: '0xc........'})

but i get some error.
please help me.
Best regards.

SocketError: Failed to open TCP connection to https:443

Hi there.

I'm trying to get up and running, and I'm doing the following:

web3 = Web3::Eth::Rpc.new host: 'https://mainnet.infura.io', port: 443, connect_options: { open_timeout: 20, read_timeout: 140, use_ssl: true, rpc_path: '/[my api key]' }

I'm getting an instance of web3 back, and when I try to run web3.eth.blockNumber, I get
SocketError: Failed to open TCP connection to https:443 (getaddrinfo: nodename nor servname provided, or not known)

Any ideas?

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.