CryptoCoinsInfoClub.com

Ethereum Parse Transaction

Ambisafe - Ethereum Panning. Part Ii. Accepting Erc20 Tokens

Ambisafe - Ethereum Panning. Part Ii. Accepting Erc20 Tokens

Ethereum Panning. Part II. Accepting ERC20 Tokens Feb. 6, 2018, 1:19 p.m. | Oleksii Matiiasevych In the previous part , we paid attention to the process of accepting ETH. In this article, we'll make a similar analysis of dealing with ERC20 tokens. Lets outline the task. I needto receive ERC20 token payments, (1) link them to a specific purchase, and (2) accumulate in a single wallet. In the off-chain world of bank transfers, this issue is usually addressed in the following way.I register a bank account and give its details to customers along with a unique purpose (which is a universally available, a standard field in a bank transfer details). A sender must specify this information while making the transaction. In this way, (2) is achieved naturally as all the transfers end up in the same place, and (1) is achieved by looking for purpose in the incoming payments. I cannot directly apply the same architecture to Ethereum because there is no such thing as purpose in the ERC20 standard. What if,instead, I create unique wallets for every purchase? This operation is fast and freeand solves (1) naturally. To solve (2), I have to add an extra step to the payment processing and sweep incoming tokens to my main wallet. After an incoming payment I cannot send a token transaction from a wallet that has 0 ETH on its balance. So, after the payment processing is triggered, I will send enough ETH to the wallet, and after it has arrived, I will make a transaction transferring tokens from the wallet. How do I know that tokens already hit the unique wallet? What will triggeran actual payment processing? A nave way to go is by polling the token balance of a unique wallet every time a new block is mined (about 15 seconds) till the moment it is greater than 0 (or some appropriate limit)and Continue reading >>

Full-stack Smart Contract Development

Full-stack Smart Contract Development

Writing, testing and deploying an Ethereum smart contract and its web interface This weekend I spent some time with my team looking into tooling and deployments particular to the Ethereum blockchain, and put together a little experiment: Forever on the Chain . Its the equivalent of a digital tattoo: a smart contract that anyone can use for free (minus transaction costs) to leave a permanent message onto the Ethereum blockchain. This message is stored in the blockchain forever, etched into thousands upon thousands of computers, unchangeable and immortal. Even though permanence is one of the core blockchain concepts, this still worried some folks, so I also wrote a non-technical post about the tool and some of the implications of blockchain technology . What follows is a smart contract tutorial. Ill walk you through the creation and testing of the critical path of this tool. This assumes you have an understanding of some Ethereum core concepts such as smart contracts, transactions, and gas. If you dont, heres an explainer to get you started. This smart contract is as simple as they come. Its only functionality is to log a message into the blockchain. This is achieved through the use of Events, as explained below. The smart contract is written in Solidity. This is a statically typed language to write Ethereum smart contracts. From the documentation : Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed to target the Ethereum Virtual Machine (EVM). Heres what the implementation of our contract looks like. * @title Recorder record a message into the blockchain * @a uthor Life on Mars Lets start by walking slowly through this code. Source files can (and should) be annotated with a so-called version pragma to re Continue reading >>

Ethslurp - Drink The Blockchain

Ethslurp - Drink The Blockchain

Download as .zip Download as .tar.gz View on GitHub The first time you slurp an Ethereum address you may simply tell it an address. If, however, you additionally provide an ABI (Application Binary Interface) file, EthSlurp can do so much more. We won't explain what an ABI is (Google it), but it's worth learning if you don't know. Ethereum transactions are very like Bitcoin transactions, in the sense that they include at least three fields: from_account, to_account, and transaction_amount. This makes perfect sense. How else would one transfer money between accounts. Of course, there are other data fields , but one in particular is of interest to us. That fields is called input. Bitcoin has an input field, but it has at most 80 bytes of storage. This is one of the important differences between Bitcoin and Ethereum. Ethereum's input field can be of any length. Why is this important? Becuase the input field is how Ethereum passes along its function calls. This is the contents of a typical Ethereum data field: 0xc9d27afe 00000000000000000000000000000000000000000000000000000000000000ff 0000000000000000000000000000000000000000000000000000000000000001 Computer gobbeldy-gook again. Using the information we find in the contract's ABI, EthSlurp is able to convert this string into this function call: Which, because this is The DAO's transaction represents a user voting on one of the proposals. Another transaction: 0x23b872dd 000000000000000000000000bf6cc4a882ace8e3a19bb8f5372280b33b2f6c9e 000000000000000000000000fbb1b73c4f0bda4f67dca266ce6ef42f520fbb98 0000000000000000000000000000000000000000000000056bc75e2d63100000 transferFrom(0xbf6cc4a882ace8e3a19bb8f5372280b33b2f6c9e, 0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98, -1) which, in the case of The DAO, means move all DAO tokens in th Continue reading >>

Wallets Ethers.js 3.0.0 Documentation

Wallets Ethers.js 3.0.0 Documentation

var privateKey = '0x0123456789012345678901234567890123456789012345678901234567890123';var wallet = new ethers.Wallet(privateKey);wallet.provider = ethers.providers.getDefaultProvider();var balancePromise = wallet.getBalance();balancePromise.then(function(balance) { console.log(balance);});var transactionCountPromise = wallet.getTransactionCount();transactionCountPromise.then(function(transactionCount) { console.log(transactionCount);}); var privateKey = '0x0123456789012345678901234567890123456789012345678901234567890123';var wallet = new ethers.Wallet(privateKey);wallet.provider = ethers.providers.getDefaultProvider();// We must pass in the amount as wei (1 ether = 1e18 wei), so we use// this convenience function to convert ether to wei.var amount = ethers.utils.parseEther('1.0');var address = '0x88a5c2d9919e46f883eb62f7b8dd9d0cc45bc290';var sendPromise = wallet.send(address, amount);sendPromise.then(function(transactionHash) { console.log(transactionHash);});// These will query the network for appropriate valuesvar options = { //gasLimit: 21000 //gasPrice: utils.bigNumberify("20000000000")};var promiseSend = wallet.send(address, amount, options);promiseSend.then(function(transaction) { console.log(transaction);}); var privateKey = '0x0123456789012345678901234567890123456789012345678901234567890123';var wallet = new ethers.Wallet(privateKey);wallet.provider = ethers.providers.getDefaultProvider('ropsten');var transaction = { // Recommendation: omit nonce; the provider will query the network // nonce: 0, // Gas Limit; 21000 will send ether to another use, but to execute contracts // larger limits are required. The provider.estimateGas can be used for this. gasLimit: 1000000, // Recommendations: omit gasPrice; the provider will query the network //gasPrice: utils.bigNumb Continue reading >>

Accessing Contracts And Transactions

Accessing Contracts And Transactions

In previous sections we have seen how contracts can be written, deployed and interacted with. Now its time to dive in the details of communicatingwith the Ethereum network and smart contracts. An Ethereum node offers a RPC interface. This interface gives apps access to the Ethereumblockchain and functionality that the node provides, such as compiling smart contract code. It uses a subset of the JSON-RPC 2.0 specification (no support for notifications or named parameters) as serialisation protocol andis available over HTTP and IPC (unix domain sockets on linux/OSX and named pipes on Windows). If you are not interested in the details but are looking for an easy to use javascript library you can skip the following sections and continue with Using Web3 . The RPC interface uses a couple of conventions that are not part of the JSON-RPC 2.0 specification: Numbers are hex encoded. This decision was made because some languages have no or limited support for working with extremly large numbers. To preventthese type of errors numbers are hex encoded and it is up to the deverloper to parse these numbers and handle them appropriately. See the hex encoding section on the wiki for examples. Default block number, several RPC methods accept a block number. In some cases its not possible to give a block number or not very convenient. Forthese cases the default block number can be one of these strings [earliest, latest, pending]. See the wiki page for a list of RPC methods that use the default block parameters. We will go through the different steps to deploy the following contract using only the RPC interface. contract Multiply7 { event Print(uint); function multiply(uint input) returns (uint) { Print(input * 7); return input * 7; }} The first thing to do is make sure the HTTP RPC inter Continue reading >>

Deep Dive Into Ethereumlogs

Deep Dive Into Ethereumlogs

Hey kids, today we are going low level trying to understand how Ethereum events and logs work. Put web3 away for a while as it abstracts things and wed like to get as bare as it gets. Smart contracts generate logs by firing events. Heres a transaction receipt that contains one log entry. The log entry consists of one topic and a data field. The first topic refers to the specific event, but we dont know which one yet. To decode the data we need to obtain ABI of the contract found in the address field. We are interested in items with the type event. Heres a sample event. > indexed_types = [i['type'] for i in e['inputs'] if i['indexed']] > indexed_names = [i['name'] for i in e['inputs'] if i['indexed']] > indexed_values = [eth_abi.decode_single(t, v) for t, v in zip(indexed_types, log['topics'][1:])] ['0x00b46c2526e227482e2ebb8f4c69e4674d262e75', > {name: value for name, value in chain(zip(names, values), zip(indexed_names, indexed_values))} {'from': '0x00b46c2526e227482e2ebb8f4c69e4674d262e75', 'to': '0x54a2d42a40f51259dedd1978f6c118a0f0eff078', Note that Ethereum always uses integers to represent numeric values, so we got the value in the minimal denomination. Move the decimal point left by decimals found in the contract, 3 in this case. The message reads: Transfer from 0x00b4 to 0x54a2 of 5,000,000 tokens. Now you are ready to do some search. You can query the blockchain using json-rpc api which is provided by full nodes like geth or Parity or a service like Infura. Bloom filters allow you to scan the entire blockchain in seconds and find logs matching the specific topic. You can also specify search range with fromBlock and toBlock, limit the search to specific contract address and omit some of the topics with null which works like a wildcard. The full specification ca Continue reading >>

Technical Introduction To Events And Logs Inethereum

Technical Introduction To Events And Logs Inethereum

A blockchain venture production studio building decentralized applications on Ethereum. Go to www.consensys.net and subscribe to our newsletter. Technical Introduction to Events and Logs inEthereum Events and logs are important in Ethereum because they facilitate communication between smart contracts and their user interfaces. In traditional web development, a server response is provided in a callback to the frontend. In Ethereum, when a transaction is mined, smart contracts can emit events and write logs to the blockchain that the frontend can then process. There are different ways to address events and logs. This technical introduction will explain some sources of confusion regarding events and some sample code for working with them. Events can be confusing because they can be used in different ways. An event for one may not look like an event for another. There are 3 main use cases for events and logs: smart contract return values for the user interface The terminology between events and logs is another source of confusion and this will be explained in the third use case. 1) Smart contract return values for the user interface The simplest use of an event is to pass along return values from contracts, to an apps frontend. To illustrate, here is the problem. function foo(int256 _value) returns (int256) { Assuming exampleContract is an instance of ExampleContract, a frontend using web3.js, can obtain a return value by simulating the contract execution: var returnValue = exampleContract.foo.call(2); However, when web3.js submits the contract call as a transaction, it cannot obtain the return value [1] : var returnValue = exampleContract.foo.sendTransaction(2, {from: web3.eth.coinbase}); console.log(returnValue) // transaction hash The return value of a sendTransaction m Continue reading >>

Ethereum Pypi

Ethereum Pypi

get_parent(block) - gets the parent of a block get_children(block) - gets the children of a block head (property) - gets the block at the head of the chain state (property) - gets the state at the head of the chain mk_poststate_of_blockhash(hash) - creates a state object after agiven block has_block(block) - is that block in the chain? Returns True/False get_chain(from, to) - roughly equivalent to[get_block_by_number(i) for i in range(from, to)], thoughautomatically stops if it reaches the head. from can be elided tostart from genesis, to can be elided to go up to the head. get_tx_position(tx) - if the transaction is in the chain, returns(blknum, index) where blknum is the block number of the blockthat contains the transaction and index is its position in theblock Contains the State class, which is used to manage a state. Main methodsare: __init__(root_hash, env, **kwargs) - initializes a state with thegiven root hash, the given env (which includes a config and database)and the given auxiliary arguments. These include: suicides - suicides (or selfdestructs, the newer morepolitically correct synonym) recent_uncles - recent uncle blocks in the chain refunds - suicide/selfdestruct refund counter Pyethereum follows a maximally state-centric model; the ONLYinformation needed to process a transaction or a block is located withinthe state itself, allowing the actual state transition logic to be avery clean apply_transaction(state, tx) andapply_block(state, block). get_balance- gets the balance of an account get_storage_data(addr, k) - gets the storage at the given key ofthe given address. Expects a key in numerical form (eg. bcow or0x636f77 is represented as 6516599). to_snapshot(root_only=False, no_prevblocks=False) - creates asnapshot for the current state. If root_only is Continue reading >>

Blockchain Developer Api For Ethereum | Blockcypher

Blockchain Developer Api For Ethereum | Blockcypher

# ^# / \ _ _# / ^ \ |_) | _ _ | / ._ |_ _ ._#< > |_) | (_) (_ |< \_ \/ |_) | | (/_ |# \ v / / |# \ /# v Welcome to BlockCyphers Ethereum API documentation! If youre familiar with our Bitcoin endpoints, youll feel right at home with our Ethereum API. However, there are a few differences, and they stem in part from the fundamental differences between Bitcoin and Ethereum. In the most abstract sense, Bitcoin and Ethereum are cousins; they both have blocks of transactions linked together into a chain, they both use Proof of Work to reach consensus (for now, as Ethereum plans to move to Proof of Stake in a future release), they are both about decentralizing trust. But thats where the similarities end. Here are just some of Ethereums differences: There are no UTXOs, only accounts (of two varieties) Block time is significantly shorter; 15 second target instead of 10 minutes Miners get rewards for including references to orphan blocks (so called uncle blocks) Ethereums scripting language is far more expressive than Bitcoins; typically advanced transactions/contracts are constructed using a higher level language then converted into EVM bytecode Ethereum has no strict cap on monetary supply (ether supply) Transactions cost gas to run (denominated in ether) depending on how computationally expensive they are to run. Blocks also have total gas limits to prevent runaway computation/keep the network decentralized. In a nutshell, Bitcoin is about decentralized, trust-minimizing, sound money. Ethereum is about decentralized, trust-minimizing, sound computation. Much more detail about these differences can be read at the Ethereum Wiki here. You can find more information at the projects webpage as well. man curl | grep -A 3 "DESCRIPTION"DESCRIPTIONcurl is a tool to transfer data from or Continue reading >>

Ethereum/web3.js - Gitter

Ethereum/web3.js - Gitter

Ethereum node JavaScript API - hi,May i know how to use the watch event in app.js of nodejs framework //this is what i wrote in app.jsopalContractInstance.output1({}).watch(function (e, log){ if (!e) { console.log('output is'+ log); }});//event in solidityevent output1(bytes32[] key); This watch function throw an error, is there any wrong in above code??? please help //got this error filterCreationErrorCallback(error); ^TypeError: filterCreationErrorCallback is not a function at Object.callback (C:\Users\farheen.thaj.khazi\Desktop\OPAL\node_modules\web3\lib\web3\filter.js:153:13) at C:\Users\farheen.thaj.khazi\Desktop\OPAL\node_modules\web3\lib\web3\method.js:142:25 at C:\Users\farheen.thaj.khazi\Desktop\OPAL\node_modules\web3\lib\web3\requestmanager.js:82:20 at XMLHttpRequest.request.onreadystatechange (C:\Users\farheen.thaj.khazi\Desktop\OPAL\node_modules\web3\lib\web3\httpprovider.js:118:13) at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\farheen.thaj.khazi\Desktop\OPAL\node_modules\xhr2\lib\xhr2.js:64:18) at XMLHttpRequest._setReadyState (C:\Users\farheen.thaj.khazi\Desktop\OPAL\node_modules\xhr2\lib\xhr2.js:354:12) at XMLHttpRequest._onHttpRequestError (C:\Users\farheen.thaj.khazi\Desktop\OPAL\node_modules\xhr2\lib\xhr2.js:544:12) at ClientRequest. (C:\Users\farheen.thaj.khazi\Desktop\OPAL\node_modules\xhr2\lib\xhr2.js:414:24) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) Continue reading >>

Web3.eth.contract Web3.js 1.0.0 Documentation

Web3.eth.contract Web3.js 1.0.0 Documentation

new web3.eth.Contract(jsonInterface[, address][, options]) Creates a new contract instance with all its methods and events defined in its json interface object. jsonInterface - Object: The json interface for the contract to instantiate address - String (optional): The address of the smart contract to call, can be added later using myContract.options.address = '0x1234..' options - Object (optional): The options of the contract. Some are used as fallbacks for calls and transactions: from - String: The address transactions should be made from. gasPrice - String: The gas price in wei to use for transactions. gas - Number: The maximum gas provided for a transaction (gas limit). data - String: The byte code of the contract. Used when the contract gets deployed . Object: The contract instance with all its methods and events. var myContract = new web3.eth.Contract([...], '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', { from: '0x1234567890123456789012345678901234567891', // default from address gasPrice: '20000000000' // default gas price in wei, 20 gwei in this case}); The options object for the contract instance. from, gas and gasPrice are used as fallback values when sending transactions. address - String: The address where the contract is deployed. See options.address . jsonInterface - Array: The json interface of the contract. See options.jsonInterface . data - String: The byte code of the contract. Used when the contract gets deployed . from - String: The address transactions should be made from. gasPrice - String: The gas price in wei to use for transactions. gas - Number: The maximum gas provided for a transaction (gas limit). myContract.options;> { address: '0x1234567890123456789012345678901234567891', jsonInterface: [...], from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697 Continue reading >>

A Gentle Introduction To Ethereum Programming, Part2

A Gentle Introduction To Ethereum Programming, Part2

Developer, security researcher, musician & chef at Zeppelin A Gentle Introduction to Ethereum Programming, Part2 This is the second part of our Ethereum introduction guide. If you havent read part 1 , I highly recommend it to better understand this post. Enjoy, and please do not hesitate to reach out with questions, corrections or feedback. 2.1. Introduction to smart contracts in Ethereum 4. A real DApp, a token marketplace coming soon 2.1. Introduction to smart contracts inEthereum Well, you already know some basics about Ethereum, youve been interacting with an Ethereum node, sent some transactions between accounts, etc. But there is something else that makes Ethereum amazing: smart contracts. As I explained in the introduction, a smart contract is a program that runs on the EVM. You can build any smart contract to do whatever you want, but today, most are being used for crowdfounding tools like ICOs or token sales. Allow me to explain these. I will start with crowdfunding, a concept that Im sure youre familiar with. Projects do a crowdfunding campaign in order to raise funds to carry out a project. You can issue a digital asset related to your project and immediately sell it to anyone in the world, for almost zero cost. This is what we call an Initial Coin Offering (ICO). To carry out an ICO with smart contracts, you just need to implement the logic that makes your digital assets tradable and valuable. Sounds great, doesnt it? These are Ethereum tokens. A token is a digital asset within the Ethereum ecosystem. Lets try to analyze all these ideas through an example. Suppose you have health food company that wants to launch a new brand. You decide to conduct an ICO to raise 20,000 ETH. You offer 10 tokens in return for every 1 ETH you collect, promising that contribut Continue reading >>

Happyfuncorp | Ethereum Programming For Web Developers

Happyfuncorp | Ethereum Programming For Web Developers

Hello, fellow web developer! If you're reading this, you're probably interested in blockchains, smart contracts, etc., as someone who actually wants to write some smart-contract code. I'm going to walk you through setting up, writing, and deploying a smart contract to a real live Ethereum blockchain, and then interacting with that contract in a browser via a web service. I'm not going to explain Blockchains 101 or Ethereum 101: there are many other places to go for that. But it's probably worth discussing Ethereum at a very high level from a developer's perspective. You don't need to care about mining or Proof-of-Work vs. Proof-of-Stake, or anything like that. But you should know that Ethereum is a decentralized virtual machine that runs on many nodes scattered around the world, and so-called "smart contracts" are code which runs (along with data which is stored) within that virtual machine, i.e. on every single node. This is obviously hugely inefficient, but it has advantages; everyone in the world can rely on this code/data, because no central service or system can tamper with it; and anyone can submit code/data to this machine without the registering or asking permission. They do, however, need to pay. Every line of code and byte of storage in Ethereum has a price. Ethereum, like Bitcoin, has a native currency, called "ether"; this is the same Ether currency that is traded on exchanges like Coinbase. When used to pay for Ethereum computing/storage, it is called "gas." For any given smart contract, gas has a "limit" and a "price." This is pretty confusing at first, but don't worry, you'll wrap your head around it eventually, and anyway this tutorial uses free fake money on a so-called "testnet" Ethereum blockchain. In principle many languages can be compiled down to Continue reading >>

How To Find $10m Just By Reading The Blockchain

How To Find $10m Just By Reading The Blockchain

How to Find $10M Just by Reading the Blockchain Two weeks ago, one Golem enthusiast and GNT holder reported a strange GNT transfer transaction bug. After investigating the data attached to the transaction, I discovered that there had to be a problem in the way the exchange was preparing data for the transaction. Oh no, I thought, this bug could be used to empty the whole GNT account on the exchange! And quite a large number of tokens were stored there! The bug was indeed the exchanges fault, but it was also related to the way Ethereum contracts see the transaction input data and Solidity ABI (e.g. the way the methods of Solidity contracts encode and decode arguments). So of course it was not specific to GNT, but indeed to all ERC20 tokens, as well as other contracts which have transfer-like methods. Yes you read it right: this could potentially work for any Ethereum-based token listed on said exchange, if only withdrawals were managed in the same way as GNT. We do not know this to be the case, but assume it was very likely. Raw Ethereum contracts have neither methods nor functions. Methods are features of high level languages like Solidity, and they use the Ethereum Contract ABI to specify how a contracts bytecode is divided into methods, as well as how different types of arguments are encoded in transaction input data. (See for a reference.) To invoke the transfer(address a, uint v) method of the GNT contract to transfer 1 GNT to address 0xabcabcabcabcabcabcabcabcabcabcabcabcabca one needs to include 3 pieces of data: 32 bytes, with the destination address (20 bytes) filled with leading zeros: 000000000000000000000000abcabcabcabcabcabcabcabcabcabcabcabcabca 32 bytes, being the value to transfer, 1 * 10 GNT: 0000000000000000000000000000000000000000000000000de0b6b3a7640 Continue reading >>

Creating Offline Ethereum Transactions In Javascript

Creating Offline Ethereum Transactions In Javascript

Creating offline Ethereum transactions in JavaScript By Mikko Ohtamaa a year ago. Tagged under ethereum , javascript , web3 , etherscan . In this blog post we show how to create Ethereum blockchain transactions programmatically in JavaScript and offline. This is the second part of tutorial blog posts continuing the earlier Ethereum JavaScript tutorial left. We bend the meaning of the word offline here a bit. We still communicate with Ethereum network to get the gas cost and the next transaction nonce. However, the private key never leaves the computer. This blog post serves mostly as an example. Advanced users can use the script presented here for doing Ether cold wallet and offline transactions. Target address, either a contract or an Ethereum account. Nonce, incremented once per transaction per account, to prevent double spend attacks. Value, how many Ethers are transferred. Can be 0 for contract calls, but you still need to pay for the gas. The maximum gas the transaction is allowed pull from the sending account. The gas price if the transaction needs a preferential treatment. Optional data payload that would include any function call and arguments encoded. Transaction is signed with the private key of the sending account address. Based on these arguments you can create a raw transaction, as a hex string, that can be pushed to the network. Pushing can happen either through EtherScan.io service or through web3.eth.sendRawTransaction API. Furthermore in this particular example we also need EtherScan.io API key - we use their API to communicate with the network The example script is available on TokenMarket Github repository . Install dependencies with NPM - see previous blog post Please note that this command line monster will go away in the future when Node.js starts Continue reading >>

More in bitcoin