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 ...
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
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 ...
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.
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 ...
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 ...
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
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 ...
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]
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 = "...
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, ...
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.
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
nodeDBVersionKey = byte("version") // Version of the database to flush if changes
nodeDBItemPrefix = byte("n:") // Identifier to prefix node ...
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.
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 ...
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 ...
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, ...
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, ...
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 ...
'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.
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 ...
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.
from typing import Callable, Iterable, List, Optional
from .ethjsonrpc ...
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))).
the decode_abi function expects binary data
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.