ethereum

Get token balance with Ethereum RPC?

无人久伴 提交于 2019-12-05 02:57:07
问题 how display balance of token through Ethereum RPC? $id = 0; $data = array(); $data['jsonrpc'] = '2.0'; $data['id'] = $id++; $data['method'] = 'eth_call'; $data['params'] = [['from' => '0x0...', 'to' => '0x0...', 'data' => 'contract byte code here 0x0...'], 'latest']; $ch = curl_init(); ... Return: {"jsonrpc":"2.0","id":0,"result":"0x"} What to do next? Call contract method balanceOf? How to do that? 回答1: To get token balance with eth_call you need to and data parameter. to is contract address

Connecting to Ethereum node in web browser

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 02:40:58
问题 I'm getting this error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545, is it running? I'm currently trying to use a Meteor app with a node on a private test network. I've also tried running it on a real node on the real network as well. I am able to access the web3.eth objects, but I can't seem to connect to my node! It's so frustrating! My app runs on http://localhost:3000 I've tried the following in launching my nodes, neither of them work (they launch okay, but I cannot

Truffle command not found after installation

╄→гoц情女王★ 提交于 2019-12-05 00:53:52
I installed truffle through npm with the following: sudo npm install -g truffle but when I run truffle list on the console it just gives me bash: truffle: command not found Please make sure you have the latest version of npm and node installed. I had the same issue, I updated npm and node to latest version and it worked. npm install -g truffle works. I had a similar problem. I ran npm i -g truffle and then when I tried to run truffle init I got an error: zsh: command not found: truffle . What solved it for me is to create a local node_modules with truffle installed in it, and then run that

How to return mapping list in Solidity? (Ethereum contract)

允我心安 提交于 2019-12-04 23:04:10
I want to make simple smart contract that has a list, can set item, and can get the list. Code in solidity: contract lister { mapping(int => string) list; int id = 0; function getList() returns ( /*HERE*/ ) { return list; } function setItemToList(string str) { list[id] = str; id++; } } I want to make getList() return the list, but return type is not compatible. How can I do that? Bulk access to lists/arrays/etc is painful in Solidity. You rarely see it in contracts. In your case, a possible solution is to provide a function to access one item, using its index, and to let the caller loops from

Send signed transactions to Ropsten or Truffle develop network with Trezor (Hardware Wallet)

谁说胖子不能爱 提交于 2019-12-04 16:23:59
问题 Im trying to integrate web3js with Trezor in a truffle dev network or using ropsten test network . The idea is to sign the transactions using the hardware wallet and then send a raw transaction using web3js Im getting that we dont have balance to make the transaction, probably because web3js isnt taking one of the 10 truffle accounts and is using the trezor address that isnt in my local network .. On ropsten i have some ethers and i get "invalid address" Is there a way to send a signed

Historical ethereum prices - Coinbase API

你。 提交于 2019-12-04 10:45:18
问题 Using the python coinbase API-- The functions-- get_buy_price , get_sell_price , get_spot_price , get_historical_data , etc... all seem to return bitcoin prices only. Is there a way of querying Ethereum prices? It would seem that currency_pair = 'BTC-USD' could be changed to something akin to currency_pair = 'ETH-USD' although this has no effect. I would expect that the API simply doesn't support this, except that the official documentation explicitly states: Get the total price to buy one

以太坊(Ethereum)开发框架 Truffle 入门(三):创建项目

别等时光非礼了梦想. 提交于 2019-12-04 07:11:23
创建项目文件夹 首先创建一个项目文件夹。你可以通过你喜欢的文件资源管理器或在命令行中执行以下命令: $ mkdir myproject 初始化你的项目 接下来,初始化你的 Truffle 项目通过在命令行执行以下命令: $ cd myproject $ truffle init 一旦执行完成,你将拥有一个如下项目结构的项目: app/ - 你的应用程序默认目录。这里包含推荐的 Javascript 和 stylesheets 文件夹,但是你完全可以自由支配这些文件的使用。 contracts/ - Truffle 项目的 solidity 合约目录。 environments/ - 放置应用程序构建文件的目录,在这里你可以重写每个环境变量配置。 test/ - 用于测试你的应用程序和智能合约的测试文件目录。 truffle.js - Truffle 项目主配置文件。 默认项目:MetaCoin 默认情况下,Truffle 给你初始化一个 MetaCoin 演示应用程序,它就像一个以太坊构建的 alt-coin 系统。你可以使用这个项目并通过浏览入门指南来快速学习 Truffle 的使用,或者删除这些文件,建立一个属于自己的项目。 英文原文: http://truffle.readthedocs.io/en/latest/getting_started/project/ 来源:

Can we create non-fungible tokens with Hyperledger?

≯℡__Kan透↙ 提交于 2019-12-04 02:01:47
问题 According to ERC-721 ERC-721 is a free, open standard that describes how to build non-fungible or unique tokens on the Ethereum blockchain. While most tokens are fungible (every token is the same as every other token), ERC-721 tokens are all unique. Is there a provision on a permissioned blockchain like hyperledger for non-fungile tokens ? 回答1: Why would you do this, since Hyperledger is a permissioned blockchain and Ethereum a public one? Anyways, if you mean to create an asset with a unique

Get token balance with Ethereum RPC?

只谈情不闲聊 提交于 2019-12-03 20:45:01
how display balance of token through Ethereum RPC? $id = 0; $data = array(); $data['jsonrpc'] = '2.0'; $data['id'] = $id++; $data['method'] = 'eth_call'; $data['params'] = [['from' => '0x0...', 'to' => '0x0...', 'data' => 'contract byte code here 0x0...'], 'latest']; $ch = curl_init(); ... Return: {"jsonrpc":"2.0","id":0,"result":"0x"} What to do next? Call contract method balanceOf? How to do that? Kris Roofe To get token balance with eth_call you need to and data parameter. to is contract address, here we need to generate the data parameter. As the doc eth_call says, data: DATA - (optional)

Connecting to Ethereum node in web browser

谁都会走 提交于 2019-12-03 17:25:05
I'm getting this error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545, is it running? I'm currently trying to use a Meteor app with a node on a private test network. I've also tried running it on a real node on the real network as well. I am able to access the web3.eth objects, but I can't seem to connect to my node! It's so frustrating! My app runs on http://localhost:3000 I've tried the following in launching my nodes, neither of them work (they launch okay, but I cannot connect to them through my browser): geth --networkid 8545 --genesis ~/genesis_block.json --datadir ~/