Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Hot answers tagged

28

Every programming language is designed for a particular operational environment and target tasks; and these constraints drive almost all design decisions on what features to support and which ones to drop. A while ago I've spent quite a lot of time to create a Go -> EVM cross compiler. I did manage to run a few trivial programs and it definitely was a lot ...


11

Vyper is the successor to Serpent. It is under active development, mainly by Vitalik himself. References: Vyper


10

With regards to why Serpent was deprecated, Vitalik recently Tweeted that he considers Serpent to be "outdated tech". The Serpent README has been updated in the last couple of days with the following: Being a low-level language, Serpent is NOT RECOMMENDED for building applications unless you really really know what you're doing. The creator ...


9

eth_getLogs returns an array of filter logs. You pass in the parameters - e.g. fromBlock, toBlock, etc. - you want to discriminate against. These are the same parameter used by eth_newFilter. eth_newFilter takes the same parameters, but returns a filterId instead of an array of logs. This ID can then be passed to eth_getFilterLogs, which returns the array ...


9

I implemented a bitcoin blockchain parser after following along with this blog post. I havent tried changing it to work with the Ethereum blockchain but maybe it can give you some guidance. Here's a parser implemented in Go to hopefully give you some Ethereum specific examples to go off of.


8

It looks like you're in Python 2. Py2 represents bytes in a latin-1 encoded string. Sometimes you'll see ascii characters, other times you'll see something like \x18 which means the byte 00011000, aka 18 in hex, or 24 as an integer. A private key is just a bunch of bytes back-to-back. raw is the binary representation of the address. The address in addr is ...


6

While Serpent uses a syntax very similar to Python, there are some important differences to be aware of: Python numbers have potentially unlimited size, Serpent numbers wrap around 2^256. For example, in Serpent the expression 3^(2^254) surprisingly evaluates to 1, even though in reality the actual integer is too large to be recorded in its entirety ...


6

pythereum and pythapp - your question tags - are Python implementations of Ethereum's core library and command line client respectively. They are orthogonal to the language in which smart contracts are written. So the short answer to your question is: no. Having said that, have a look at Serpent: https://github.com/ethereum/wiki/wiki/Serpent


6

The problem is solc is not installed on your pc. get it installed through sudo add-apt-repository ppa:ethereum/ethereum sudo apt-get update sudo apt-get install solc or you can go here


5

Use t.gas_limit and t.gas_price. For gas limit, since you usually only want to set it once: Set t.gas_limit before t.state(). Example t.gas_limit = 3000000 Otherwise can do self.s.abi_contract(code, gas=3000000,... (You can set the gas_limit much higher for testing purposes so that you can deploy a very big contract, but best to keep it lower than the ...


5

With a recent (>=1.0) version of pysha3 you can recreate the method ID with: from sha3 import keccak_256 sha3_hash = keccak_256("baz(uint32,bool)").hexdigest() method_id = "0x"+sha3_hash[:8] print method_id If your pysha3 is old (eg pinned atpysha3==0.3) you need: from sha3 import sha3_256 sha3_hash = sha3_256("baz(uint32,bool)").hexdigest() method_id = "...


5

v3 vs v4 Update: The question was written using web3.py v3, when v3 was the latest stable version. v4 is now stable, and preferred. Note that there are docs available for both versions: v3 (old) and v4 (current). eventFilter in v3 eventFilter is only available in v4. The simplest solution is now to upgrade, with pip install --upgrade web3. If you can't, ...


5

MetaMask is a browser extension, so it's only available from code running in the browser. So to use it from web3.py, you'd first have to find a way to run Python code in the browser. This is perhaps technically possible but definitely not worth the trouble. If you're writing code in the browser, stick with JavaScript (and therefore web3.js).


4

TestRPC doesn't support past events unfortunately. You could try using a private Geth chain as detailed here.


4

The contents of the database are blob-ified, so you'll have to de-blobbify them to get anything human-readable. The layout can be found in database.go: // Schema layout for the node database var ( nodeDBVersionKey = []byte("version") // Version of the database to flush if changes nodeDBItemPrefix = []byte("n:") // Identifier to prefix node ...


4

Yes since testrpc provides exactly a Remote Procedure Call interface you can use EthJsonRpc as a client library to interface with the simulated blockchain. Just fire up testrpc in a console and it should work. I use testrpc together with truffle and it should be no different for a Python based client.


4

You can change the start gas here: self.mycontract = self.s.abi_contract(code, gas=3000000, language='solidity', sender=t.k0) But I'm not sure if that's the actual problem


4

All of this has already been explored in the comments but I'll summarise as an answer! Executing/calling from bash This is explained pretty thoroughly in the Homestead Guide to Accessing Contracts and Transactions. From the very basics, Ethereum has an RPC (Remote procedure call) interface, as explained excellently by the Wikipedia RPC page. Ethereum's ...


4

Ethereum smart contracts need to compile to EVM (Ethereum Virtual Machine) bytecode. There are no Python to EVM compilers, and for some of the challenges, see What is the merit of creating new smart contract languages like Solidity instead of using other languages? The options are to use a Python-like language Serpent or a recent (Nov 2016) experimental ...


4

Take a look at our security audit for Serpent to see why. Basically, it's very a bad quality, untested and unmaintained insecure project.


4

What can I do to ensure my transactions hit the blockchain as fast as possible? Most simply, the miner who finds the next block must have your transaction in their pool, and choose to include it. Because they choose, you cannot "ensure" inclusion, only increase your chances. In an ideal world, for maximum speed, you would peer directly with all the miners, ...


4

As Rob suggests, what you could do -since iterating a mapping is not possible, and if it was an array, it would be expensive- is to compute the values on the fly. Say you have several scores mapped to addresses. Address - Score 0x1 - 3 0x2 - 4 0x3 - 2 Your original intention was to iterate over every element of the mapping to increase the scores, ...


4

Unfortunately, there is no "return value" for a transaction. There are two typical patterns to simulate a return value: Mutate the state via a transaction and then read the resulting state by calling a view function. (Note that this gives you the state at the time you call the view function, not necessarily the state right after the transaction, since other ...


4

'the-passphrase' is password to be supplied by you, which will be used to encrypt new account's private key. So when you will access this new account, system will ask for password which was used to encrypt account's private key.


3

The answer is patience. pyethapp is rather a proof of concept implementation than a production ready node. I had to wait several hours until I noticed the client started to synchronize the main network. It's very slowly sync'ing for some days now and I have only the first million blocks on disk. Keep waiting for the rest. TL;DR pyethapp works, but prepare ...


3

Here is an example of a listener: """Poll Ethereum blockchain, install log hooks to call contracts. Using geth JSON RPC API: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter Copyright 2016 Mikko Ohtamaa - Licensed under MIT license. """ import logging from typing import Callable, Iterable, List, Optional import datetime from .ethjsonrpc ...


3

This is an old question that never got answered, but it can be easily done by accessing this web API: https://www.4byte.directory


3

I have had a similar issue and discovered that the eth_sign RPC call does not sign the passed message, but a transformation of it. Quote from https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign The sign method calculates an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))). (Where len(...


3

Solved the decode_abi function expects binary data filterChanges=[{u'address': u'0x3673d5b436089c9aa3f59df5062c7431c86c21d7', u'blockHash': u'0xabbaaefe73c34ddfce9c3656ede6a754d105f1a2b43fbcf28baad633703d095c', u'blockNumber': u'0xb914d', u'data': u'...


3

This is not possible, a smart contract can't use a python library or any library not supported by the compiler. you would only use the libraries written in the languages supported by the EVM like serpent or solidity.


Only top voted, non community-wiki answers of a minimum length are eligible