# Welcome to Expanse

Even the biggest ideas start with small steps. If you can DREAM it, Expanse can help you DO it. Let us take you from imagination to REAL-WORLD USE. Come build your next project on the Expanse.

Welcome to the Expanse documentation system, we have created the documentation based on your profile, whether you are a beginner, a mining enthusiast or a developer, you can find here the necessary documentation to launch your next great idea with Expanse Technology.

The value and potential of Expanse is limited only by the imagination and talent of the diverse people around the globe involved in its journey.

#### WHY CHOOSE EXPANSE?

* First and most enduring fork of Ethereum&#x20;
* Decentralized and open source&#x20;
* Unique dApps focused on real-world use&#x20;
* Extensive industry partnerships&#x20;
* Consistent growth and stability&#x20;
* Dedicated team of forward-thinking veterans


# Where to start?

If you’re still trying to figure out what BLOCKCHAIN is and the difference between a token and a coin, don’t worry. You don’t have to be a cryptocurrency expert to join the Expanse.Tech journey.

## UNDERSTAND SOME CONCEPTS FIRST

### What is Expanse?

Expanse is an open blockchain platform forked from Ethereum that lets anyone build and use decentralized applications that run on blockchain technology. Like Bitcoin and Ethereum, no one controls or owns Expanse – it is an open-source project built by many people around the world. But unlike the Bitcoin protocol, Expanse was designed to be adaptable and flexible. It is easy to create new applications on the Expanse platform.

### Expanse Virtual Machine

Expanse is a programmable blockchain. Rather than give users a set of pre-defined operations (e.g. bitcoin transactions), Expanse allows users to create their own operations of any complexity they wish. In this way, it serves as a platform for many different types of decentralized blockchain applications, including but not limited to cryptocurrencies.

### How does Expanse work?

Expanse incorporates many features and technologies that will be familiar to users of Bitcoin, while also introducing many modifications and innovations of its own. Whereas the Bitcoin blockchain was purely a list of transactions, Expanse’s basic unit is the account. The Expanse blockchain tracks the state of every account, and all state transitions on the Expanse blockchain are transfers of value and information between accounts.

### Mining

The word mining originates in the context of the gold analogy for crypto currencies. Gold or precious metals are scarce, so are digital tokens, and the only way to increase the total volume is through mining. This is appropriate to the extent that in Expanse too, the only mode of issuance post launch is via mining. Unlike these examples however, mining is also the way to secure the network by creating, verifying, publishing and propagating blocks in the blockchain. Mining Expanse = Securing the Network = Verifying Computation

**Need more?** If you want know more about Expanse please visit our Documentation site, Video Channels, Blog and Discord Channel.

### You are invited

You are invited to become a part of the Expanse community! Here are a few ways you can participate:

* Follow all Expanse social media accounts.&#x20;
* Talk about the project and share it with friends and family on your social networks to help spread awareness (organic growth).&#x20;
* Join the Expanse Discord or Telegram channels.

&#x20;If you’re a developer, feel free to reach out to the Expanse team if interested in building on top of&#x20;


# How does Expanse works?

Expanse incorporates many features and technologies that will be familiar to users of Bitcoin, while also introducing many modifications and innovations of its own.

Whereas the Bitcoin blockchain was purely a list of transactions, Expanse’s basic unit is the account. The Expanse blockchain tracks the state of every account, and all state transitions on the Expanse blockchain are transfers of value and information between accounts. There are two types of accounts:

* Externally Owned Accounts (EOAs), which are controlled by private keys
* Contract Accounts, which are controlled by their contract code and can only be “activated” by an EOA

For most users, the basic difference between these is that human users control EOAs – because they can control the private keys which give control over an EOA. Contract accounts, on the other hand, are governed by their internal code. If they are “controlled” by a human user, it is because they are programmed to be controlled by an EOA with a certain address, which is in turn controlled by whoever holds the private keys that control that EOA. The popular term “smart contracts” refers to code in a Contract Account – programs that execute when a transaction is sent to that account. Users can create new contracts by deploying code to the blockchain.

Contract accounts only perform an operation when instructed to do so by an EOA. So it is not possible for a Contract account to be performing native operations like random number generation or API calls – it can do these things only if prompted by an EOA. This is because Expanse requires nodes to be able to agree on the outcome of computation, which requires a guarantee of strictly deterministic execution.

Like in Bitcoin, users must pay small transaction fees to the network. This protects the Expanse blockchain from frivolous or malicious computational tasks, like DDoS attacks or infinite loops. The sender of a transaction must pay for each step of the “program” they activated, including computation and memory storage. These fees are paid in amounts of Expanse’s native value-token, expanse.

These transaction fees are collected by the nodes that validate the network. These “miners” are nodes in the Expanse network that receive, propogate, verify, and execute transactions. The miners then group the transactions – which include many updates to the “state” of accounts in the Expanse blockchain – into what are called “blocks”, and miners then compete with one another for their block to be the next one to be added to the blockchain. Miners are rewarded with expanse for each successful block they mine. This provides the economic incentive for people to dedicate hardware and electricity to the Expanse network.

Just as in the Bitcoin network, miners are tasked with solving a complex mathematical problem in order to successfully “mine” a block. This is known as a “Proof of Work”. Any computational problem that requires orders of magnitude more resources to solve algorithmically than it takes to verify the solution is a good candidate for proof of work. In order to discourage centralisation due to the use of specialised hardware (e.g. ASICs), as has occurred in the Bitcoin network, Expanse chose a memory-hard computational problem. If the problem requires memory as well as CPU, the ideal hardware is in fact the general computer. This makes Expanse’s Proof of Work ASIC-resistant, allowing a more decentralized distribution of security than blockchains whose mining is dominated by specialized hardware, like Bitcoin.


# What is our Blockchain?

A blockchain is a distributed computing architecture where every network node executes and records the same transactions, which are grouped into blocks.

**A next generation Blockchain**

Blockchain technology is the technological basis of Bitcoin, first described by its mysterious author Satoshi Nakamoto in his white paper “Bitcoin: A Peer-to-Peer Electronic Cash System”, published in 2008. While the use of blockchains for more general uses was already discussed in the original paper, it was not until a few years later that blockchain technology emerged as a generic term.&#x20;

A blockchain is a distributed computing architecture where every network node executes and records the same transactions, which are grouped into blocks. Only one block can be added at a time, and every block contains a mathematical proof that verifies that it follows in sequence from the previous block. In this way, the blockchain’s “distributed database” is kept in consensus across the whole network. Individual user interactions with the ledger (transactions) are secured by strong cryptography. Nodes that maintain and verify the network are incentivized by mathematically enforced economic incentives coded into the protocol.

### **LIST OF EXCHANGES EXP IS LISTED ON**

* [Bittrex.com](https://bittrex.com/Market/Index?MarketName=BTC-EXP)
* [dovewallet.com](https://dovewallet.com/)
* [Hitbtc.com](https://hitbtc.com/es/EXP-to-BTC)
* [Graviex.net](https://graviex.net/)
* [Upbit.com](https://upbit.com/exchange?code=CRIX.UPBIT.BTC-EXP)
* [BoaExchange.com](https://boaexchange.com/)


# What is our denomination?

Expanse has a metric system of denominations used as units of Expanse. Each denomination has its own unique name.

Expanse has a metric system of denominations used as units of Expanse. Each denomination has its own unique name (some bear the family name of seminal figures playing a role in evolution of computer science and cryptoeconomics). The smallest denomination aka base unit of Expanse is called Wei. Below is a list of the named denominations and their value in Wei. Following a common (although somewhat ambiguous) pattern, Expanse also designates a unit (of 1e18 or one quintillion Wei) of the currency. Note that the currency is not called Expanse as many mistakenly think, nor is Expanse a unit.


# What is our EVM?

Expanse allows users to create their own operations of any complexity they wish. In this way, it serves as a platform for many different types of decentralized blockchain applications.

## Expanse Virtual Machine

Expanse is a programmable blockchain. Rather than give users a set of pre-defined operations (e.g. bitcoin transactions), Expanse allows users to create their own operations of any complexity they wish. In this way, it serves as a platform for many different types of decentralized blockchain applications, including but not limited to cryptocurrencies.

Expanse in the narrow sense refers to a suite of protocols that define a platform for decentralised applications. At the heart of it is the [Expanse Virtual Machine (“EVM”)](http://docs.expanse.tech/en/latest/contracts-and-transactions/developer-tools.html#the-evm), which can execute code of arbitrary algorithmic complexity. In computer science terms, Expanse is “Turing complete”. Developers can create applications that run on the EVM using friendly programming languages modelled on existing languages like JavaScript and Python.

Like any blockchain, Expanse also includes a peer-to-peer network protocol. The Expanse blockchain database is maintained and updated by many nodes connected to the network. Each and every node of the network runs the EVM and executes the same instructions. For this reason, Expanse is sometimes described evocatively as a “world computer”.

This massive parallelisation of computing across the entire Expanse network is not done to make computation more efficient. In fact, this process makes computation on Expanse far slower and more expensive than on a traditional “computer”. Rather, every Expanse node runs the EVM in order to maintain consensus across the blockchain. Decentralized consensus gives Expanse extreme levels of fault tolerance, ensures zero downtime, and makes data stored on the blockchain forever unchangeable and censorship-resistant.

The Expanse platform itself is featureless or value-agnostic. Similar to programming languages, it is up to entrepreneurs and developers to decide what it should be used for. However, it is clear that certain application types benefit more than others from Expanse’s capabilities. Specifically, expanse is **suited for applications that automate direct interaction between peers or facilitate coordinated group action across a network**. For instance, applications for coordinating peer-to-peer marketplaces, or the automation of complex financial contracts. Bitcoin allows for individuals to exchange cash without involving any middlemen like financial institutions, banks, or governments. Expanse’s impact may be more far-reaching. In theory, financial interactions or exchanges of any complexity could be carried out automatically and reliably using code running on Expanse. Beyond financial applications, any environments where trust, security, and permanence are important – for instance, asset-registries, voting, governance, and the internet of things – could be massively impacted by the Expanse platform.


# What is the Expanse Supply?

The total supply of EXP is 11.11m + ( 800,000 \* 8 + number of mined blocks after block 800,000 \* 4 ). The current number in circulation is only 1m + ( 800,000 \* 8 + Number of mined blocks after block 800,000 \* 4 ). The original block reward was 8 EXP, after block 800,000, the reward was reduced to 4 EXP.


# How to get an Expanse's Wallet Address?

Many have asked for the best way to get a wallet address on Expanse, one of the most popular forms used to be Coinomi but since Coinomi stopped listing it there have been many questions. (By the way Coinomi started charging huge sums for being on their app, that’s not cool!). So we leave you here a guide on two platforms to obtain your Expanse Wallet Address.

## 1- The official way – The Mist Wallet

How to get your Expanse wallet address in 3 steps.

### Step 1

First, we must download the Wallet from the official Expanse site and select your operating system and version. [Download it here](https://expanse.tech/downloads/)![](https://lh4.googleusercontent.com/ZJ5VhLIGB1317QtYlNKv6JsWM_uEpug4ojR1noPOJiZe8kAltBwPp4mCnOSkMBLoW2waLUiZugfCkrTj1uOSItyFb1k4j2fhI-JD8TtU8vwEmOfypq5h3eR5UITKdl-PN0m7D0AW)

Install it on your computer and wait for it to sync. This may take a while depending on your internet speed.

### Step 2&#x20;

Press the Add an account button and enter a password that you can remember and confirm that password.![](https://lh5.googleusercontent.com/fOYNkSF3ys0ZoVRAXKiIyaNxnQLlWzPCrYwLrjftn2OhlMzBv1GYet_FWTFyZecA5i5qLlu57wpmUM6fU7mmGNNU83bLp1O4UDUoDqhuZ5BVtY07hYJlOZHNxvp-yaiisb22y_tL)

Make sure you backup your key files AND password! You can find your keyfiles folder using the main menu -> Accounts -> Backup -> Accounts. Keep a copy of the “keystore” folder where you can’t lose it!![](https://lh6.googleusercontent.com/OUke1iSw88eHBeLwqADYZrIOdFNf3WGPiIx8zglV-Ux4CV9zos2UZrknNDnQXlznDP9OWO4VbhIqgtdhjji2--mQlaq_8OsoPl20Eu2DYR7w4gi62UdzQw8NR2aFCY1xcCyLk7pi)

### Step 3

Click on the generated Wallet Address and you can change the name, copy the address and start using it.![](https://lh3.googleusercontent.com/RZMvwO2rNB_Frx-ZIzwxRZ5qmfEI5ntDt1rBbhm8qGaFMV6gNpzpDTtGo2huuNp4ibutp58hf-81lP4y22U7wxxnmXIb3jpslVk5v3nkvxbG14ybfNRmUve-6qoto467SHxnAdl3)

## 2. My Ether wallet

How to get your Expanse wallet Address in a simple anonymous wallet![](https://expanse.tech/wp-content/uploads/2020/11/Screen-Shot-2020-11-16-at-2.43.55-PM-1024x454.png)

1. Enter [https://www.myetherwallet.com](https://www.myetherwallet.com/) and click on Create new Wallet purple section
2. Accept the terms from MEW and be aware that you are responsible for your keys and passwords.
3. You will have to view the full wizard before you start.
4. You will find 3 types of creating a wallet
   1. Download the app
   2. By keystore file:&#x20;
      1. You have to enter a password you can remember&#x20;
      2. Press Download the Keystore, save the file on your computer.
      3. Then press access my wallet button.&#x20;
      4. You will get 4 options to do it Mew Wallet, hardware wallet, Mew CX or Software
      5. Click on Software and then select the UTC file and enter the password you enter before.
      6. On the right side change the network to Expanse.&#x20;
      7. Then you can use the address to send your Expanse.&#x20;
   3. By Mnemonic Phrase
      1. You will get 12 words write them down (you can configure this as 12 or 24 words)
      2. You can also add an extra word for security, please write these 12 words without them you will not be able to access the wallet and you will lose your EXP.
      3. You will have to reenter some words to verify your wallet.&#x20;
      4. Every time you want to access your wallet you will have to enter these 12 words.
      5. Click on Software and then select the UTC file and enter the password you enter before.
      6. On the right side change the network to Expanse.&#x20;
      7. Then you can use the address to send your Expanse.

### 3. How to buy Expanse using Dove Wallet

![](https://expanse.tech/wp-content/uploads/2020/11/Screen-Shot-2020-11-16-at-1.42.43-PM-1024x530.png)[https://dovewallet.com](https://dovewallet.com/)

1. Enter <https://dovewallet.com/en/register>
2. Fill the form information&#x20;
3. Check your email with the confirmation and click on confirm.&#x20;
4. Click on the Wallet link on the header menu (besides the logo)
5. On the right side go down and look for BTC press on Deposit
6. Now get some Expanse by clicking on this link <https://dovewallet.com/en/trade/spot/exp-btc>
7. There are other options like Bittrex or visit [https://expanse.tech](https://expanse.tech/) for more exchanges.&#x20;


# What third-party wallets I can use?

WALLETS YOU CAN USE - Hardware and software wallets for expanse

![](https://expanse.tech/wp-content/uploads/2021/01/mycrypto-wallet-logo.jpg)

### MyCrypto

MyCrypto is an open-source, client-side tool for generating ether wallets, handling ERC-20 tokens, and interacting with the blockchain more easily. Developed by and for the community since 2015, we’re focused on building awesome products that put the power in people’s hands. Reduce risk by using the MyCrypto downloadable app

![](https://expanse.tech/wp-content/uploads/2021/01/mew-wallet-logo.jpg)

### MyEtherWallet

MyEtherWallet (our friends call us MEW) is a free, client-side interface helping you interact with the Ethereum blockchain. Our easy-to-use, open-source platform allows you to generate wallets, interact with smart contracts, and so much more. Get it here

![](https://expanse.tech/wp-content/uploads/2021/01/metamask-wallet-logo.jpg)

### Metamask Wallet

Buy, store, send and swap tokens Available as a browser extension and as a mobile app, MetaMask equips you with a key vault, secure login, token wallet, and token exchange—everything you need to manage your digital assets. You can get Metamask here

![](https://expanse.tech/wp-content/uploads/2021/01/dove-wallet-logo.jpg)

### Dove Wallet

Dove Wallet is the easiest service to deposit, transfer, trade cryptocurrency. We hope anyone can enjoy their financial life anywhere, anytime Super happy! Get Dove here

![](https://expanse.tech/wp-content/uploads/2021/01/guarda-wallet-logo-hor.jpg)

### Guarda Wallet

Manage Crypto Anywhere Store, send, stake, exchange, and buy Bitcoin, Ethereum, Monero, Polkadot, Tezos, Tron, and other coins. Be in full control of your funds while maintaining privacy and anonimity. Secure and convenient mobile crypto wallet to buy, stake, store, and exchange cryptocurrencies, tokens, and stablecoins. Sync your wallets across web or desktop. Web Wallet \[…]

![](https://expanse.tech/wp-content/uploads/2021/01/opolo-wallet-logo.jpg)

### Opolo Wallet

Financial transactions are a daily part of life and the internet has made it easier and more secure to do financial transactions in the form of cryptocurrency. Cryptocurrency is the internet-based medium of exchange which uses different cryptographic functions to handle financial transactions. To make financial transactions easier and secure, hardware wallets are used to hold the \[…]


# How  to configure Expanse on Metamask?

Metamask is the way to integrate your Expanse wallet to Eggswap and one of the most important questions is how to configure it, first you need to add the Extension on Chrome Browser.

## Step 1

Go to the [https://metamask.io](https://metamask.io/) ![](https://lh6.googleusercontent.com/T_rgnkAO4ASJ-Y1p0uimrSIo7f_Dk13KAblWD1buSMGEcNkMZzdvPFXccKHK81OB7xtTunvpQC2nrpcGBoZ4QpuIuNScItITU2NEo2lAV8hyT_eHTDjc77L-U76LVYRYYS5HbKXh)

## Step 2

Click “Get Chrome Extension” to install Metamask.![](https://lh5.googleusercontent.com/rYWKPgyjrjFWV9sdoeBKTYKubSvBPsTuX4Nft0myy7GE2kPIKcRm2sJoPWibPofXJ_RMoDu_OiwOwVdHXCuc9BAvu5AxOaxqmFiKpfzXK6qXQfFB0qYk13BzVeblGmSK6UO3UcjS)

## Step 3

Click “Add to Chrome” in the upper right.

## Step 4

Click “Add Extension” to complete the installation.

## Step 5

Click on the Metamask logo in the upper right hand corner of your Google chrome browser, then read and agree to the terms and conditions or go to [https://eggs.cool](https://eggs.cool/) and click on Unlock Wallet![](https://lh6.googleusercontent.com/gOk8f2aMj5fZ8V7BuNlyLCjoRLFxUNH1Wu6W7Hyi4Y9IuQ06kpm_tL0IYfyzf3sKkgLpyzW_dcXFYzJi7TOBBs6UPpayXjLLRZ9H0FJHi3Th7dyxLkvwsini-KuRRseR2lNrnDXi)

## Step 6

Enter a password and click “Create” to create your wallet.

## Step 7

You will see a set of 12 “seed words” for your vault. Please save them.

## Step 8

Click “I’ve Copied It Somewhere Safe” once your seed words file has been secured. You’ll be taken into your Metamask wallet!

## Step 9

Click on the Ethereum mainnet and then Custom RPC and enter this information for Expanse:

* Name: Expanse
* Node – [https://node.expanse.tech](https://node.eggs.cool/rpc)
* Chainid – 2
* Symbol – EXP
* Block Explore URL – <https://explorer.expanse.tech>

![](https://lh3.googleusercontent.com/XMw09iBWaKUVdaXDCBewrWue1Jf21oqVtTrVDcXqgiOlxq_Cy8GJPvbgNW0FemgLETE8jz6ofKGzvN1T5Pe5Cpl7gExf3x4Rqpii9UBwkftqLPHySrEy2Ge1HPcxGCJhG9SCkO3X)

## Step 10

Add your Expanse wallet, you can create one or add your own in 2 ways by entering your private key or import your key (json file in the keystore folder), click on the circle in the right top corner and click on import. ![](https://lh6.googleusercontent.com/Vbz7PXxI8eiSR5qCi7w_GXSQf1yA3hhGKwStWG2-PcPu1AM4kZD0WkdAiKJvQbl2bs6ySwnmRtENMlBFECPelSGS9tDUIzPjj3oN40drgmJV7AxS9qq-t0jP3zvF3ax4CbSoM1X8)![](https://lh6.googleusercontent.com/eE9QqSrSPWSjoOhbfcOMK24_PFrTGW_yKr7isq3CQ9uO5u9V8qVI6M3TX1mjHT31emHdUNvdlLiR320K3_G3sXGqVSRj9U6IcjpxwrF0H_HwkmrQWUGl_hc319dKXFluvzu9jpwq)![](https://lh5.googleusercontent.com/Jk15Y9XbIkGOEJ0pQDvA2t0pixIpgahFq1qfpz_L5QaBJMQO8o0hrSQncJu7FkqeYswjUo2sDss__RorJmX2Edwb4OFdfoCBEt4FDI2HV-KR1ltOko_GEfKC7dEB_n_4Z5SUNE8d)


# FAQ

Beginner Frequently Asked Questions

## What is Expanse?

Pronounced \[ik-spans]

Noun 1.An uninterrupted space or area; a wide extent of anything: an expanse of water. 2.Something that is spread out, especially over a relatively large area: that great expanse, the sky. 3.Expansion; extension:

Expanse is a decentralized programmable platform that utilizes and allows for the application of blockchain technology in many facets of life. Expanse is the first stable fork of Ethereum.

Like Bitcoin, Ethereum utilizes a blockchain for security and transparency. Expanse, like Bitcoin, is also tradeable directly as Expanse (EXP). However, Expanse also allows for the creation of “smart contracts,” allowing developers to use blockchain technology, via Expanse, in their own programmable applications.

## What is Expanse token (EXP)?

EXP is the name for the token Expanse uses. EXP is generated via algorithmic mining and is the basis of the Expanse network. Expanse serves as the blockchain technology platform for “smart contracts,” which often utilize “tokens.”

## How is Expanse different from Bitcoin?

Expanse creates an ecosystem for the utilization of blockchain in everyday transactions and is designed with this intention. Bitcoin, on the other hand, was created as a form of electronic cash. Expanse uses similar blockchain technology to maintain all of the benefits of Bitcoin, but Expanse also allows for an infrastructure of applications that can extend beyond the exchange of currency.

## Why use Expanse (EXP) instead of a traditional smart contract token?

The best use case example of why, is comparable to Ethereum. Although the concept behind both Ethereum and Expanse is similar, Expanse is faster, more stable, and scales. Consider the scenario where CryptoKitties was introduced onto the Ethereum blockchain. Due to the massive increase in traffic, the entire network of Ethereum was affected, essentially slowing down transaction times. If CryptoKitties was built using the Expanse blockchain, the traffic would not be affected.

Below is a side by side comparison

## How can I help support the Expanse project?

You are invited to become a part of the Expanse community! Here are a few ways you can participate:

* Follow all Expanse social media accounts.&#x20;
* Talk about the project and share it with friends and family on your social networks to help spread awareness (organic growth).&#x20;
* Join the Expanse Discord or Telegram channels.

&#x20;If you’re a developer, feel free to reach out to the Expanse team if interested in building on top of the Expanse Network.


# How to add a token to Metamask?

The way to show your balance on every token is by adding them to your wallet, to do that you will have to:

## Step 1

Press on the Add token button at the bottom of the account![](https://lh5.googleusercontent.com/1oN9mZ3GhQuKafhnjGMoA3q5TjHUo8fXIhOord-bdLjlwjxt3ARojmwnnsOlbmU3iyeSYm2jkmGubScQeIfCswyiPwrNwwQ_x0OLeXECPpDamoUufGwjRGFSUTSMXLuxNaA8GLcO)

## Step 2

Press on Custom token and enter the information for the most important Expanse tokens or a token deployed by you. You will need the Token contract address and Metamask will add the Token Symbol and the Decimals precision. Once you enter the token contract address the Symbol and Decimals will be autofill. ![](https://lh3.googleusercontent.com/aa3nkbZwepj1PWp6_k2G0TiSke3WZtC-L2vTP2stSYCElCrIxETVqZ2DuEHPLHDOevu0pTzxI7opaTnMIsVRZa3iYOjSE-dQ3gh-bQSWMa8iFSGa1uQC_CpHUuFiWHqRydhYwYBX)

## Token contract Address

Here is a list of the Expanse Tokens on Eggswap

* LoveToken – 0x9D2761A714b5b2EfA325a8a3eee21BE32AACeB4A
* T64 – 0x72332c512bf2dA5A7Cd11752b380F7d8fcBba847
* LAB – 0x3b4cfcc4532eec161860cb6544f49947544d940d
* WEXP 0x331631B4bb93b9B8962faE15860BD538a389395A
* PEX 0x4f5ec5a69dbe12c48ca1edc9c52b1e8896aed932
* GXP – 0x29a828f7d34769ae5d788bbbe505fa5b2abadf06
* Lab – 0xa887adb722cf15bc1efe3c6a5d879e0482e8d197


# How To Manually Burn LAB/PEX To Mint EGGS Using Remix

```
Prerequisites
- MetaMask
- An account with LAB or PEX
- Convert Ether to WEI https://eth-converter.com/

Contracts you will need.
- ERC20.sol - https://gist.github.com/chrisfranko/cf633bd6b21bdd430e7fc10c9cef19ff
- BurnToMint.sol - https://gist.github.com/chrisfranko/6ee76a7c6f8a666d265a9639d71c837d

Address’s
- LAB - 0x3b4cfcc4532eec161860cb6544f49947544d940d
- PEX - 0x4f5ec5a69dbe12c48ca1edc9c52b1e8896aed932
- BurnToMint - 0x5AD51ce8073ff3aBf48a2966f720eA4e09ec1648

Byte32
- LAB: 0x4c41420000000000000000000000000000000000000000000000000000000000
- PEX: 0x5045580000000000000000000000000000000000000000000000000000000000

Steps

1. Setup Remix
    1. Go To https://remix.ethereum.org
    2. Click “Plugins” at the bottom of left hand navigation menu.
    3. Activate Solidity Compiler
    4. Activate Deploy & Run Transactions
2. Add Contracts
    1. Click the File Explorer Icon
    2. Click the + sign to create a new file
    3. Create file named BurnToMint.sol
    4. Go to BurnToMint.sol source and copy the source code
    5. Paste burntoMint source into the BurnToMint file created on Remix
    6. Click the + sign
    7. Create file named Token.sol
    8. Go to ERC20.sol source and copy the source code
    9. Paste ERC20 source into the ERC20 file created on Remix
3. Load Burn To Mint Contracts
    1. Click on the BurnToMint TAB
    2. Select The “Solidity Compiler” from the left menu
    3. Click “Compile BurnToMint.sol”
    4. Click “Deploy & Run Transactions” from the left menu
    5. Change “Environment” to “Injected Web3” from the drop down menu
    6. Select the account that has the EXP and Tokens
    7. Paste the BurnToMint address into the blue “At Address” input 
    8. Click “At Address”
4. Load BurntoMint at Tokens
    1. Click the ERC20 TAB
    2. Select The “Solidity Compiler” from the left menu
    3. Click “Compile ERC20.sol”
    4. Click “Deploy & Run Transactions” from the left menu
    5. Change “Environment” to “Injected Web3” from the drop down menu
    6. Select the account that has the EXP and Tokens
    7. Paste the TOKEN address into the blue “At Address” input 
    8. Click “At Address”
5. Approve Tokens
    1. At the Deploy & Run Transactions View scroll to the bottom of the page
    2. Select the token you’d like to approve
    3. Find the orange “Approve” option and click the down arrow
    4. Paste “BurnToMint” address into “spender”
    5. Paste “100000000000000000000000000” into “amount”
    6. Click “transact”
    7. Click “ok”
    8. Follow meta mask prompts
6. BurnToMint
    1. At the Deploy & Run Transactions View scroll to the bottom of the page
    2. Select “BurnToMint”
    3. Select “burn tokens” and click the black arrow
    4. Paste the corresponding Bytes32 for the token you want to burn
    5. Use the Ether Converter to convert the amount of tokens you want to burn into WEI
    6. Click transact
    7. Click ok
    8. Follow the metamask prompts
7. Check Balance
    1. Go to eggs.cool or eggs.cool/ex/
```


# Where to start?

Are you part of the mining workforce, using your skills and resources to help keep crypto’s infrastructure running?

### GETTING STARTED

That's ok, we can help you start your journey to mine on Expanse Blockchains by introducing you some basic concepts and listing some useful links. And you can also count with our help by using our Help Center or by reaching out our community on Discord.

## UNDERSTAND SOME CONCEPTS FIRST

### What is Expanse?

Expanse is an open blockchain platform forked from Ethereum that lets anyone build and use decentralized applications that run on blockchain technology. Like Bitcoin and Ethereum, no one controls or owns Expanse – it is an open-source project built by many people around the world. But unlike the Bitcoin protocol, Expanse was designed to be adaptable and flexible. It is easy to create new applications on the Expanse platform.

### Expanse Virtual Machine

Expanse is a programmable blockchain. Rather than give users a set of pre-defined operations (e.g. bitcoin transactions), Expanse allows users to create their own operations of any complexity they wish. In this way, it serves as a platform for many different types of decentralized blockchain applications, including but not limited to cryptocurrencies.

### How does Expanse Work?

Expanse incorporates many features and technologies that will be familiar to users of Bitcoin, while also introducing many modifications and innovations of its own. Whereas the Bitcoin blockchain was purely a list of transactions, Expanse’s basic unit is the account. The Expanse blockchain tracks the state of every account, and all state transitions on the Expanse blockchain are transfers of value and information between accounts.

### Mining

The word mining originates in the context of the gold analogy for crypto currencies. Gold or precious metals are scarce, so are digital tokens, and the only way to increase the total volume is through mining. This is appropriate to the extent that in Expanse, the only mode of issuance post launch is via mining. Unlike these examples however, mining is also the way to secure the network by creating, verifying, publishing and propagating blocks in the blockchain. Mining Expanse = Securing the Network = Verifying Computation

### **Start mining now**

Expanse, like all blockchain technologies, uses an incentive-driven model of security. Consensus is based on choosing the block with the highest total difficulty. Miners produce blocks which the others check for validity.


# What are the mining rewards?

The successful PoW miner of the winning block receives:

* A static block reward for the ‘winning’ block, consisting of exactly 8.0 Expanse
* cost of the gas expended within the block – an amount of expanse that depends on the current gas price
* an extra reward for including uncles as part of the block, in the form of an extra 1/32 per uncle included

All the gas consumed by the execution of all the transactions in the block submitted by the winning miner is paid by the senders of each transaction. The gas cost incurred is credited to the miner’s account as part of the consensus protocol. Over time, it is expected these will dwarf the static block reward.

#### MINING POOLS

* [EXP.POOL](http://pool.expanse.tech/)
* [Ethertrench](http://exp.ethertrench.com/)
* [HODLPool](http://exp.hodlpool.com/)
* [Suprnova](https://exp.suprnova.cc/)
* [Dwarfpool](http://dwarfpool.com/exp)
* [Dwarfpool iTunes monitoring tool](https://itunes.apple.com/gb/app/dpool-tracker-expanse/id1356723711?mt=8)
* [Akasha](http://exp.akasha-pool.eu/)
* [MinandoAndo](http://exp.minandoando.com/)
* [Minerpool.net](http://exp.minerpool.net/)
* [ServeHttp](http://exppool.servehttp.com/#/)
* [Pandapool.io](https://pandapool.io/)
* [Clona.ru](http://clona.ru:8083/)
* [Exp.solopool.org](https://exp.solopool.org/)
* [AIO Miner](http://aiominer.com/) (All in one mining software
* [2Miners.co](https://2miners.com/exp-mining-pool)
* [uCrypto.net](https://ucrypto.net/currency/?curr=EXP)
* [Poolhub.org](http://exp.poolhub.org/#/)
* [BekoPool](https://bekopool.io/)
* [DigiPools](http://exp.digipools.org/)
* [Bitpool](https://www.bitpoolmining.com/poolstatsexp)
* [ExpMine.Pro](https://expmine.pro/)

####


# How to send Expanse?

The [Expanse Wallet](https://github.com/expanse-org/mist/releases) supports sending expanse via a graphical interface.

Expanse can also be transferred using the **gexp console**.

\> var sender **=** exp.account&#x73;**\[**&#x30;**]**;\
\> var receiver **=** exp.account&#x73;**\[**&#x31;**]**;\
\> var amount **=** web3.toWe&#x69;**(**&#x30;.01, “expanse”**)**\
\> exp.sendTransactio&#x6E;**({**&#x66;rom:sender, to:receiver, value: amoun&#x74;**})**

For more information of Expanse transfer transactions, see [Account Types, Gas, and Transactions](http://docs.expanse.tech/en/latest/contracts-and-transactions/account-types-gas-and-transactions.html#account-types-gas-and-transactions).

Expanse is unique in the realm of cryptocurrencies in that expanse has utility value as a cryptofuel, commonly referred to as “gas”. Beyond transaction fees, gas is a central part of every network request and requires the sender to pay for the computing resources consumed. The gas cost is dynamically calculated, based on the volume and complexity of the request and multiplied by the current gas price. Its value as a cryptofuel has the effect of increasing the stability and long-term demand for expanse and Expanse as a whole. For more information, see [Account Types, Gas, and Transactions](http://docs.expanse.tech/en/latest/contracts-and-transactions/account-types-gas-and-transactions.html#account-types-gas-and-transactions).


# What is GAS in Expanse?

Gas is supposed to be the constant cost of network resources/utilization. Users want the real cost of sending a transaction to always be the same, so users cannot really expect Gas to be issued, currencies in general are volatile.

So instead, we issue Expanse whose value is supposed to vary, but also implement a Gas Price in terms of Expanse. If the price of Expanse goes up, the Gas Price in terms of Expanse should go down to keep the real cost of Gas the same.

Gas has multiple associated terms with it: Gas Prices, Gas Cost, Gas Limit, and Gas Fees. The principle behind Gas is to have a stable value for how much a transaction or computation costs on the Expanse network.

* Gas Cost is a static value for how much a computation costs in terms of Gas, and the intent is that the real value of the Gas never changes, so this cost should always stay stable over time.
* Gas Price is how much Gas costs in terms of another currency or token like Expanse. To stabilize the value of gas, the Gas Price is a floating value such that if the cost of tokens or currency fluctuates, the Gas Price changes to keep the same real value. The Gas Price is set by the equilibrium price of how much users are willing to spend, and how much processing nodes are willing to accept.
* Gas Limit is the maximum amount of Gas that can be used per block, it is considered the maximum computational load, transaction volume, or block size of a block, and miners can slowly change this value over time.
* Gas Fee is effectively the amount of Gas needed to be paid to run a particular transaction or program (called a contract). The Gas Fees of a block can be used to imply the computational load, transaction volume, or size of a block. The gas fees are paid to the miners (or bonded contractors in PoS).

More articles on GAS can be found below.

* <https://www.reddit.com/r/ethereum/comments/271qdz/can_someone_explain_the_concept_of_gas_in_ethereum/>
* <https://www.reddit.com/r/ethereum/comments/3fnpr1/can_someone_possibly_explain_the_concept_of/>
* <https://www.reddit.com/r/ethereum/comments/49gol3/can_ether_be_used_as_a_currency_eli5_ether_gas/>


# What is the mining algo?

Our algorithm, [Ethash](https://github.com/expanse-org/wiki/wiki/Ethash) (previously known as Dagger-Hashimoto), is based around the provision of a large, transient, randomly generated dataset which forms a DAG (the Dagger-part), and attempting to solve a particular constraint on it, partly determined through a block’s header-hash.

It is designed to hash a fast verifiability time within a slow CPU-only environment, yet provide vast speed-ups for mining when provided with a large amount of memory with high-bandwidth. The large memory requirements mean that large-scale miners get comparatively little super-linear benefit. The high bandwidth requirement means that a speed-up from piling on many super-fast processing units sharing the same memory gives little benefit over a single unit. This is important in that pool mining have no benefit for nodes doing verification, thus discourageing centralisation.

Communication between the external mining application and the Expanse daemon for work provision and submission happens through the JSON-RPC API. Two RPC functions are provided; exp\_getWork and exp\_submitWork.

These are formally documented on the [JSON-RPC API](https://github.com/expanse-org/wiki/wiki/JSON-RPC) wiki article under [miner](https://github.com/expanse-org/go-expanse/wiki/JavaScript-Console#miner).

In order to mine you need a fully synced Expanse client that is enabled for mining and at least one expanse account. This account is used to send the mining rewards to and is often referred to as coinbase or etherbase. Visit the “[Creating an account](http://docs.expanse.tech/en/latest/account-management.html#creating-an-account)” section of this guide to learn how to create an account.

**Warning:** Ensure your blockchain is fully synchronised with the main chain before starting to mine, otherwise you will not be mining on the main chain.


# What is CPU Mining?

You can use your computer’s central processing unit (CPU) to mine expanse. This is no longer profitable, since GPU miners are roughly two orders of magnitude more efficient. However, you can use CPU mining to mine on the Morden testnet or a private chain for the purposes of creating the expanse you need to test contracts and transactions without spending your real expanse on the live network.

**Note:** The testnet expanse has no value other than using it for testing purposes (see [Test Networks](http://docs.expanse.tech/en/latest/network/test-networks.html#test-networks)).

#### **USING GEXP** <a href="#using-gexp" id="using-gexp"></a>

When you start up your expanse node with gexp it is not mining by default. To start it in CPU mining mode, you use the –mine [command line option](https://github.com/expanse-org/go-expanse/wiki/Command-Line-Options). The -minerthreadsparameter can be used to set the number parallel mining threads (defaulting to the total number of processor cores).

gexp –mine –minerthreads=4

You can also start and stop CPU mining at runtime using the [console](https://github.com/expanse-org/go-expanse/wiki/JavaScript-Console#adminminerstart). miner.start takes an optional parameter for the number of miner threads.

\> miner.start(8)\
true\
\> miner.stop()\
true

Note that mining for real expanse only makes sense if you are in sync with the network (since you mine on top of the consensus block). Therefore the exp blockchain downloader/synchroniser will delay mining until syncing is complete, and after that mining automatically starts unless you cancel your intention with miner.stop().

In order to earn expanse you must have your **etherbase** (or **coinbase**) address set. This etherbase defaults to your primary account. If you don’t have an etherbase address, then gexp –mine will not start up.

You can set your etherbase on the command line:

gexp –etherbase 1 –mine  2>> gexp.log // 1 is index: second account by creation order OR\
gexp –etherbase ‘0xa4d8e9cae4d04b093aac82e6cd355b6b963fb7ff’ –mine 2>> gexp.log

You can reset your etherbase on the console too:

miner.setEtherbase(exp.accounts\[2])

Note that your etherbase does not need to be an address of a local account, just an existing one.

There is an option [to add extra Data](https://github.com/expanse-org/go-expanse/wiki/JavaScript-Console#minersetextra) (32 bytes only) to your mined blocks. By convention this is interpreted as a unicode string, so you can set your short vanity tag.

miner.setExtra(“BORDERLESS”)\
…\
debug.printBlock(131805)\
BLOCK(be465b020fdbedc4063756f0912b5a89bbb4735bd1d1df84363e05ade0195cb1): Size: 531.00 B TD: [643485290485](tel:643485290485) {\
NoNonce: ee48752c3a0bfe3d85339451a5f3f411c21c8170353e450985e1faab0a9ac4cc\
Header:\
\[\
…\
&#x20;      Coinbase:           a4d8e9cae4d04b093aac82e6cd355b6b963fb7ff\
&#x20;      Number:            131805\
&#x20;      Extra:            ΞTHΞЯSPHΞЯΞ\
…\
}

You can check your hashrate with [miner.hashrate](https://github.com/expanse-org/go-expanse/wiki/JavaScript-Console#adminminerhashrate), the result is in H/s (Hash operations per second).

**>** miner.hashrate\
712000

After you successfully mined some blocks, you can check the expanse balance of your etherbase account. Now assuming your etherbase is a local account:

**>** exp.getBalance(exp.coinbase).toNumber();\
‘34698870000000’

In order to spend your earnings on gas to transact, you will need to have this account unlocked.

**>** personal.unlockAccount(exp.coinbase)\
Password\
**true**

You can check which blocks are mined by a particular miner (address) with the following code snippet on the console:

**function** minedBlocks(lastn, addr) {\
&#x20;addrs **=** \[];\
&#x20;**if** (**!**&#x61;ddr) {\
&#x20;  addr **=** exp.coinbase\
&#x20;}\
&#x20;limit **=** exp.blockNumber **–** lastn\
&#x20;**for** (i **=** exp.blockNumber; i **>=** limit; &#x69;**—**) {\
&#x20;  **if** (exp.getBlock(i).miner **==** addr) {\
&#x20;    addrs.push(i)\
&#x20;  }\
&#x20;}\
&#x20;**return** addrs\
}\
// scans the last 1000 blocks and returns the blocknumbers of blocks mined by your coinbase\
// (more precisely blocks the mining reward for which is sent to your coinbase).\
minedBlocks(1000, exp.coinbase);\
//\[352708, 352655, 352559]

Note that it will happen often that you find a block yet it never makes it to the canonical chain. This means when you locally include your mined block, the current state will show the mining reward credited to your account, however, after a while, the better chain is discovered and we switch to a chain in which your block is not included and therefore no mining reward is credited. Therefore it is quite possible that as a miner monitoring their coinbase balance will find that it may fluctuate quite a bit.


# What is GPU Mining?

#### **HARDWARE** <a href="#hardware" id="hardware"></a>

The algorithm is memory hard and in order to fit the DAG into memory, it needs 1-2GB of RAM on each GPU. If you get Error GPU mining. GPU memory fragmentation? you do not have enough memory. The GPU miner is implemented in OpenCL, so AMD GPUs will be ‘faster’ than same-category NVIDIA GPUs. ASICs and FPGAs are relatively inefficient and therefore discouraged. To get openCL for your chipset and platform, try:

* [AMD SDK openCL](http://developer.amd.com/tools-and-sdks/opencl-zone/amd-accelerated-parallel-processing-app-sdk)
* [NVIDIA CUDA openCL](https://developer.nvidia.com/cuda-downloads)

#### **UBUNTU LINUX SET-UP** <a href="#ubuntu-linux-set-up" id="ubuntu-linux-set-up"></a>

For this quick guide, you’ll need Ubuntu 14.04 or 15.04 and the fglrx graphics drivers. You can use NVidia drivers and other platforms, too, but you’ll have to find your own way to getting a working OpenCL install with them, such as [Genoil’s ethminer fork](http://cryptomining-blog.com/tag/ethminer/).

If you’re on 15.04, Go to “Software and Updates > Additional Drivers” and set it to “Using video drivers for the AMD graphics accelerator from fglrx”.

If you’re on 14.04, go to “Software and Updates > Additional Drivers” and set it to “Using video drivers for the AMD graphics accelerator from fglrx”. Unfortunately, for some of you this will not work due to a known bug in Ubuntu 14.04.02 preventing you from switching to the proprietary graphics drivers required to GPU mine.

So, if you encounter this bug, and before you do anything else, go to “Software and updates > Updates” and select “Pre-released updates trusty proposed”. Then, go back to “Software and Updates > Additional Drivers” and set it to “Using video drivers for the AMD graphics accelerator from fglrx”). After rebooting, it’s well worth having a check that the drivers have now indeed been installed correctly (For example by going to “Additional Drivers” again).

Whatever you do, if you are on 14.04.02 do not alter the drivers or the drivers configuration once set. For example, the usage of aticonfig –initial (especially with the -f, –force option) can ‘break’ your setup. If you accidentally alter their configuration, you’ll need to de-install the drivers, reboot, reinstall the drivers and reboot.

#### **MAC SET-UP** <a href="#mac-set-up" id="mac-set-up"></a>

wget <http://developer.download.nvidia.com/compute/cuda/7\\_0/Prod/local\\_installers/cuda\\_7.0.29\\_mac.pkg\\>
sudo installer -pkg \~/Desktop/cuda\_7.0.29\_mac.pkg -target /\
brew update\
brew tap expanse/expanse\
brew reinstall cpp-expanse –with-gpu-mining –devel –headless –build-from-source

You check your cooling status:

aticonfig –adapte&#x72;**=**&#x30; –od-gettemperature

#### **WINDOWS SET-UP** <a href="#windows-set-up" id="windows-set-up"></a>

[Download the latest Eth++ installation](https://github.com/expanse-org/webthree-umbrella/releases) and choose ethminer at the “Choose Components” screen of the installation screen.

#### **USING ETHMINER WITH GEXP** <a href="#using-ethminer-with-gexp" id="using-ethminer-with-gexp"></a>

gexp account new // Set-up expanse account **if** you **do** not have one\
gexp –rpc –rpccorsdomain localhost 2>> gexp.log &\
ethminer -G  // -G **for** GPU, -M **for** benchmark\
tail -f gexp.log

ethminer communicates with gexp on port 8545 (the default RPC port in gexp). You can change this by giving the –rpcport option to gexp. Ethminer will find gexp on any port. Note that you need to set the CORS header with –rpccorsdomain localhost. You can also set port on ethminer with -F <http://127.0.0.1:3301>. Setting the ports is necessary if you want several instances mining on the same computer, although this is somewhat pointless. If you are testing on a private chain, we recommend you use CPU mining instead.

**Note:** You do **not** need to give gexp the –mine option or start the miner in the console unless you want to do CPU mining on TOP of GPU mining.

If the default for ethminer does not work try to specify the OpenCL device with: –opencl-device Xwhere X is {0, 1, 2,…}. When running ethminer with -M (benchmark), you should see something like:

Benchmarking on platform: **{** “platform”: “NVIDIA CUDA”, “device”: “GeForce GTX 750 Ti”, “version”: “OpenCL 1.1 CUDA” **}**\
\
\
Benchmarking on platform: **{** “platform”: “Apple”, “device”: “Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz”, “version”: “OpenCL 1.2 ” **}**

To debug gexp:

gexp  –rpccorsdomain “localhost” –verbosity 6 2>> gexp.log

To debug the miner:

make -DCMAKE\_BUILD\_TYP&#x45;**=**&#x44;ebug -DETHASHC&#x4C;**=**&#x31; -DGU&#x49;**=**&#x30;\
gdb –args ethminer -G -M

**Note:** Hashrate info is not available in gexp when GPU mining.

Check your hashrate with ethminer, miner.hashrate will always report 0.

#### **USING ETHMINER WITH EXP** <a href="#using-ethminer-with-exp" id="using-ethminer-with-exp"></a>

**Mining on a single GPU**

In order to mine on a single GPU all that needs to be done is to run exp with the following arguments:

exp -v 1 -a 0xcadb3223d4eebcaa7b40ec5722967ced01cfc8f2 –client-name “OPTIONALNAMEHERE” -x 50 -m on -G

* -v 1 Set verbosity to 1. Let’s not get spammed by messages.
* -a YOURWALLETADDRESS Set the coinbase, where the mining rewards will go to. The above address is just an example. This argument is really important, make sure to not make a mistake in your wallet address or you will receive no expanse payout.
* –client-name “OPTIONAL” Set an optional client name to identify you on the network
* -x 50 Request a high amount of peers. Helps with finding peers in the beginning.
* -m on Actually launch with mining on.
* -G set GPU mining on.

While the client is running you can interact with it using either gexp attach\` or \[ethconsole]\(<https://github.com/expanse-org/expanse-console>).

**Mining on a multiple GPUs**

Mining with multiple GPUs and exp is very similar to mining with gexp and multiple GPUs. Ensure that an exp node is running with your coinbase address properly set:

exp -v 1 -a 0xcadb3223d4eebcaa7b40ec5722967ced01cfc8f2 –client-name “OPTIONALNAMEHERE” -x 50 -j

Notice that we also added the -j argument so that the client can have the JSON-RPC server enabled to communicate with the ethminer instances. Additionally we removed the mining related arguments since ethminer will now do the mining for us. For each of your GPUs execute a different ethminer instance:

ethminer –no-precompute -G –opencl-device X

Where X is the index number corresponding to the openCL device you want the ethminer to use {0, 1, 2,…}. In order to easily get a list of OpenCL devices you can execute ethminer –list-devices which will provide a list of all devices OpenCL can detect, with also some additional information per device.

Below is a sample output:

\[0] GeForce GTX 770\
&#x20;  CL\_DEVICE\_TYPE: GPU\
&#x20;  CL\_DEVICE\_GLOBAL\_MEM\_SIZE: [4286345216](tel:4286345216)\
&#x20;  CL\_DEVICE\_MAX\_MEM\_ALLOC\_SIZE: [1071586304](tel:1071586304)\
&#x20;  CL\_DEVICE\_MAX\_WORK\_GROUP\_SIZE: 1024

Finally the –no-precompute argument requests that the ethminers don’t create the DAG of the next epoch ahead of time. Although this is not recommended since you’ll have a mining interruption every time when there’s an epoch transition.

**Benchmarking**

Mining power tends to scale with memory bandwidth. Our implementation is written in OpenCL, which is typically supported better by AMD GPUs over NVidia. Empirical evidence confirms that AMD GPUs offer a better mining performance in terms of price than their NVidia counterparts.

To benchmark a single-device setup you can use ethminer in benchmarking mode through the -M option:

ethminer -G -M

If you have many devices and you’ll like to benchmark each individually, you can use the –opencl-device option similarly to the previous section:

ethminer -G -M –opencl-device X

Use ethminer –list-devices to list possible numbers to substitute for the X {0, 1, 2,…}.

To start mining on Windows, first [download the gexp windows binary](https://build.expanse.tech/builds/Windows%20Go%20master%20branch/).

* Unzip Gexp (right-click and select unpack) and launch Command Prompt. Use cd to navigate to the location of the Gexp data folder. (e.g. cd / to go to the C: drive)
* Start gexp by typing gexp –rpc.

As soon as you enter this, the Expanse blockchain will start downloading. Sometimes your firewall may block the synchronisation process (it will prompt you when doing so). If this is the case, click “Allow access”.

* First [download and install ethminer](http://cryptomining-blog.com/tag/ethminer-cuda-download/), the C++ mining software (your firewall or Windows itself may act up, allow access)
* Open up another Command Prompt (leave the first one running!), change directory by typing cd /Program\ Files/Expanse(++)/release
* Now make sure gexp has finished syncing the blockchain. If it is not syncing any longer, you can start the mining process by typing ethminer -G at the command prompt

At this point some problems may appear. If you get an error, you can abort the miner by pressing Ctrl+C. If the error says “Insufficient Memory”, your GPU does not have enough memory to mine expanse.\ <br>


# What is Pool Mining?

/ Mining pools are cooperatives that aim to smooth out expected revenue by pooling the mining power of participating miners. In return, they usually charge you 0-5% of your mining rewards. The mining pool submits blocks with proof of work from a central account and redistributes the reward to participants in proportion to their contributed mining power.

**Warning:** Most mining pools involve third party, central components which means they are not trustless. In other words, pool operators can run away with your earnings. Act with caution. There are a number of trustless, decentralised pools with open source codebase.

**Warning:** Mining pools only outsource proof of work calculation, they do not validate blocks or run the VM to check state transitions brought about by executing the transactions. This effectively make pools behave like single nodes in terms of security, so their growth poses a centralisation risk of a [51% attack](https://learncryptography.com/cryptocurrency/51-attack). Make sure you follow the network capacity distribution and do not allow pools to grow too large.

#### **MINING POOLS** <a href="#mining-pools" id="mining-pools"></a>

* <http://pool.expanse.tech/>
* <https://exp.suprnova.cc/>
* <http://dwarfpool.com/exp>
* <http://pooleum.com/>
* <http://exp.akasha-pool.eu/>
* <https://expanse.miningpoolhub.com/>
* [https://exp.clona.ru](https://exp.clona.ru/)
* <http://exppool.servehttp.com/#>
* <https://megapool.io/exp>
* <https://poolmining.org/pool/exp>
* <http://exp.ethertrench.com/>
* <http://expanse.ftlpool.com/>
* <http://exp.minandoando.com/>
* <https://exppool.maxhash.org/>
* <https://2miners.com/>
* <http://exp.ehashcoins.org/>
* [http://exp.firepool.ru](http://exp.firepool.ru/)


# Where to start?

This section is designed to support software developers who want to create projects on the Expanse.Tech™ blockchain.

Learn about the advantages in regard to speed, efficiency, scalability and power you can realize by choosing Expanse. You will also find information about how to connect to the Expanse Network and get access to developer tools.

### What is Expanse?

Expanse is an open blockchain platform forked from Ethereum that lets anyone build and use decentralized applications that run on blockchain technology. Like Bitcoin and Ethereum, no one controls or owns Expanse – it is an open-source project built by many people around the world. But unlike the Bitcoin protocol, Expanse was designed to be adaptable and flexible. It is easy to create new applications on the Expanse platform.

### Expanse Virtual Machine

Expanse is a programmable blockchain. Rather than give users a set of pre-defined operations (e.g. bitcoin transactions), Expanse allows users to create their own operations of any complexity they wish. In this way, it serves as a platform for many different types of decentralized blockchain applications, including but not limited to cryptocurrencies.

### How does Expanse Work?

Expanse incorporates many features and technologies that will be familiar to users of Bitcoin, while also introducing many modifications and innovations of its own. Whereas the Bitcoin blockchain was purely a list of transactions, Expanse’s basic unit is the account. The Expanse blockchain tracks the state of every account, and all state transitions on the Expanse blockchain are transfers of value and information between accounts.

### Mining

The word mining originates in the context of the gold analogy for crypto currencies. Gold or precious metals are scarce, so are digital tokens, and the only way to increase the total volume is through mining. This is appropriate to the extent that in Expanse too, the only mode of issuance post launch is via mining. Unlike these examples however, mining is also the way to secure the network by creating, verifying, publishing and propagating blocks in the blockchain. Mining Expanse = Securing the Network = Verifying Computation


# What is the Expanse Network?

The basis for decentralized consensus is the peer-to-peer network of participating nodes which maintain and secure the blockchain. See Mining.

#### **EXPANSE NETWORK STATS** <a href="#expanse-network-stats" id="expanse-network-stats"></a>

[ExpStats.net](http://stats.expanse.tech/) is a dashboard of live statistics of the Expanse network. This dashboard displays important information such as the current block, hash difficulty, gas price, and gas spending. The nodes shown on the page are only a selection of actual nodes on the network. Anyone is allowed to add their node to the EthStats dashboard. The [Eth-Netstats README on Github](https://github.com/cubedro/exp-netstats) describes how to connect.

#### **PUBLIC, PRIVATE, AND CONSORTIUM BLOCKCHAINS** <a href="#public-private-and-consortium-blockchains" id="public-private-and-consortium-blockchains"></a>

Most Expanse projects today rely on Expanse as a public blockchain, which grants access to a larger audience of users, network nodes, currency, and markets. However, there are often reasons to prefer a private blockchain or consortium blockchain (among a group of trusted participants). For example, a number of companies in verticals, like banking, are looking to Expanse as a platform for their own private blockchains.

Below is an excerpt from the blog post On Public and Private Blockchains that explains the difference between the three types of blockchains based on permissioning:

* **Public blockchains**: a public blockchain is a blockchain that anyone in the world can read, anyone in the world can send transactions to and expect to see them included if they are valid, and anyone in the world can participate in the consensus process – the process for determining what blocks get added to the chain and what the current state is. As a substitute for centralized or quasi-centralized trust, public blockchains are secured by cryptoeconomics – the combination of economic incentives and cryptographic verification using mechanisms such as proof of work or proof of stake, following a general principle that the degree to which someone can have an influence in the consensus process is proportional to the quantity of economic resources that they can bring to bear. These blockchains are generally considered to be “fully decentralized”.
* **Consortium blockchains**: a consortium blockchain is a blockchain where the consensus process is controlled by a pre-selected set of nodes; for example, one might imagine a consortium of 15 financial institutions, each of which operates a node and of which 10 must sign every block in order for the block to be valid. The right to read the blockchain may be public, or restricted to the participants, and there are also hybrid routes such as the root hashes of the blocks being public together with an API that allows members of the public to make a limited number of queries and get back cryptographic proofs of some parts of the blockchain state. These blockchains may be considered “partially decentralized”.
* **Private blockchains**: a fully private blockchain is a blockchain where write permissions are kept centralized to one organization. Read permissions may be public or restricted to an arbitrary extent. Likely applications include database management, auditing, etc internal to a single company, and so public readability may not be necessary in many cases at all, though in other cases public auditability is desired.

While these private/consortium blockchains may not have any connection to the public blockchain, they still contribute to the overall Expanse ecosystem by investing in Expanse software development. Over time, this translates into software improvements, shared knowledge, and job opportunities.


# How to connect to the Expanse Network?

Gexp continuously attempts to connect to other nodes on the network until it has peers.

Gexp continuously attempts to connect to other nodes on the network until it has peers. If you have UPnP enabled on your router or run Expanse on an Internet-facing server, it will also accept connections from other nodes.

Gexp finds peers through something called the discovery protocol. In the discovery protocol, nodes are gossipping with each other to find out about other nodes on the network. In order to get going initially, gexp uses a set of bootstrap nodes whose endpoints are recorded in the source code.

**Checking connectivity and ENODE IDs**

To check how many peers the client is connected to in the interactive console, the net module has two attributes that give you info about the number of peers and whether you are a listening node.

\> net.listening\
true\
\
\> net.peerCount\
4

To get more information about the connected peers, such as IP address and port number, supported protocols, use the peers() function of the admin object. admin.peers() returns the list of currently connected peers.

\> admin.peers\
\[{\
&#x20;    ID: ‘a4de274d3a159e10c2c9a68c326511236381b84c9ec52e72ad732eb0b2b1a2277938f78593cdbe734e6002bf23114d434a085d260514ab336d4acdc312db671b’,\
&#x20;    Name: ‘Gexp/v0.9.14/linux/go1.4.2’,\
&#x20;    Caps: ‘exp/60’,\
&#x20;    RemoteAddress: ‘5.9.150.40:30301’,\
&#x20;    LocalAddress: ‘192.168.0.28:39219’\
}, {\
&#x20;    ID: ‘a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c’,\
&#x20;    Name: ‘Gexp/v0.9.15/linux/go1.4.2’,\
&#x20;    Caps: ‘exp/60’,\
&#x20;    RemoteAddress: ‘52.16.188.185:30303’,\
&#x20;    LocalAddress: ‘192.168.0.28:50995’\
}, {\
&#x20;    ID: ‘f6ba1f1d9241d48138136ccf5baa6c2c8b008435a1c2bd009ca52fb8edbbc991eba36376beaee9d45f16d5dcbf2ed0bc23006c505d57ffcf70921bd94aa7a172’,\
&#x20;    Name: ‘pyethapp\_dd52/v0.9.13/linux2/py2.7.9’,\
&#x20;    Caps: ‘exp/60, p2p/3’,\
&#x20;    RemoteAddress: ‘144.76.62.101:30303’,\
&#x20;    LocalAddress: ‘192.168.0.28:40454’\
}, {\
&#x20;ID: ‘f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0’,\
&#x20;Name: ‘++exp/Zeppelin/Rascal/v0.9.14/Release/Darwin/clang/int’,\
&#x20;Caps: ‘exp/60, shh/2’,\
&#x20;RemoteAddress: ‘129.16.191.64:30303’,\
&#x20;LocalAddress: ‘192.168.0.28:39705’\
} ]

To check the ports used by gexp and also find your enode URI run:

\> admin.nodeInfo\
{\
&#x20;Name: ‘Gexp/v0.9.14/darwin/go1.4.2’,\
&#x20;NodeUrl: ‘enode://3414c01c19aa75a34f2dbd2f8d0898dc79d6b219ad77f8155abf1a287ce2ba60f14998a3a98c0cf14915eabfdacf914a92b27a01769de18fa2d049dbf4c17694@\[::]:30303’,\
&#x20;NodeID: ‘3414c01c19aa75a34f2dbd2f8d0898dc79d6b219ad77f8155abf1a287ce2ba60f14998a3a98c0cf14915eabfdacf914a92b27a01769de18fa2d049dbf4c17694’,\
&#x20;IP: ‘::’,\
&#x20;DiscPort: 30303,\
&#x20;TCPPort: 30303,\
&#x20;Td: ‘2044952618444’,\
&#x20;ListenAddr: ‘\[::]:30303’\
}


# How to download the Blockchain Faster

When you start an Expanse client, the Expanse blockchain is automatically downloaded. The time it takes to download the Expanse blockchain can vary based on client, client settings, connection speed, and number of peers available. Below are some options for more quickly obtaining the Expanse blockchain.

#### **USING GEXP** <a href="#using-gexp" id="using-gexp"></a>

If you are using the gexp client, there are some things you can do to speed up the time it takes to download the Expanse blockchain. If you choose to use the –fast flag to perform an Expanse fast sync, you will not retain past transaction data.

**Note:** You cannot use this flag after performing all or part of a normal sync operation, meaning you should not have any portion of the Expanse blockchain downloaded before using this command. [See this Expanse Stack.Exchange answer for more information](https://expanse.stackexchange.com/questions/1845/why-isnt-fast-sync-the-default).

Below are some flags to use when you want to sync your client more quickly.

–fast

This flag enables fast syncing through state downloads rather than downloading the full block data. This will also reduce the size of your blockchain dramatically. NOTE: –fast can only be run if you are syncing your blockchain from scratch and only the first time you download the blockchain for security reasons. [See this Reddit post for more information](https://www.reddit.com/r/expanse/comments/3y9316/gexp_fast_option_question/).

–cache=1024

Megabytes of memory allocated to internal caching (min 16MB / database forced). Default is 16MB, so increasing this to 256, 512, 1024 (1GB), or 2048 (2GB) depending on how much RAM your computer has should make a difference.

–jitvm

This flag enables the JIT VM.

Full example command with console:

gexp –fast –cache=1024 –jitvm console

For more discussion on fast syncing and blockchain download times, [see this Reddit post](https://www.reddit.com/r/expanse/comments/46c4ga/lets_benchmark_the_clients/).

#### **EXPORTING/IMPORTING THE BLOCKCHAIN** <a href="#exporting-importing-the-blockchain" id="exporting-importing-the-blockchain"></a>

If you already have a full Expanse node synced, you can export the blockchain data from the fully synced node and import it into your new node. You can accomplish this in gexp by exporting your full node with the command gexp export filename and importing the blockchain into your node using gexp import filename. see [this link](http://docs.expanse.tech/en/latest/network/staticnodes)\ <br>


# What are the static, trusted and boot Nodes?

Gexp supports a feature called static nodes if you have certain peers you always want to connect to. Static nodes are re-connected on disconnects. You can configure permanent static nodes by putting something like the following into \<datadir>/static-nodes.json (this should be the same folder that your chaindata and keystore folders are in)

\[\
&#x20;    “enode://f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0\@33.4.2.1:30303”,\
&#x20;    “enode://pubkey\@ip:port”\
]

You can also add static nodes at runtime via the Javascript console using admin.addPeer()

\> admin.addPeer(“enode://f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0\@33.4.2.1:30303”)

#### **COMMON PROBLEMS WITH CONNECTIVITY** <a href="#common-problems-with-connectivity" id="common-problems-with-connectivity"></a>

Sometimes you just can’t get connected. The most common reasons are:

* Your local time might be incorrect. An accurate clock is required to participate in the Expanse network. Check your OS for how to resync your clock (example sudo ntpdate -s time.nist.gov) because even 12 seconds too fast can lead to 0 peers.
* Some firewall configurations can prevent UDP traffic from flowing. You can use the static nodes feature or admin.addPeer() on the console to configure connections by hand.

To start gexp without the discovery protocol, you can use the –nodiscover parameter. You only want this if you are running a test node or an experimental test network with fixed nodes.\ <br>


# What are the test Networks?

### **MORDEN TESTNET** <a href="#morden-testnet" id="morden-testnet"></a>

Morden is a public Expanse alternative testnet. It is expected to continue throughout the Frontier and Homestead milestones of the software.

#### **USAGE** <a href="#usage" id="usage"></a>

**exp (C++ client)**

This is supported natively on 0.9.93 and above. Pass the –morden argument in when starting any of the clients. e.g.:

**PyEthApp (Python client)**

PyEthApp supports the morden network from v1.0.5 onwards:

**gexp (Go client)**

#### **DETAILS** <a href="#details" id="details"></a>

All parameters are the same as the main Expanse network except:

* Network Name: **Morden**
* Network Identity: 2
* genesis.json (given below);
* Initial Account Nonce (IAN) is 2^20 (instead of 0 in all previous networks).
  * All accounts in the state trie have nonce >= IAN.
  * Whenever an account is inserted into the state trie it is initialised with nonce = IAN.
* Genesis generic block hash: 0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303
* Genesis generic state root: f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9

**Morden’s genesis.json**

#### **GETTING MORDEN TESTNET EXPANSE** <a href="#getting-morden-testnet-expanse" id="getting-morden-testnet-expanse"></a>

Two ways to obtain Morden testnet expanse:

* Mine using your CPU/GPU, (see [Mining](http://docs.expanse.tech/en/latest/mining.html#mining)).
* Use the [Expanse wei faucet](https://zerogox.com/expanse/wei_faucet).


# How to setup a local private testate

## **SETTING UP A LOCAL PRIVATE TESTNET**

### **EXP (C++ CLIENT)** <a href="#exp-c-client" id="exp-c-client"></a>

It is possible to connect to or create a new network by using the –genesis and –config.

It is possible to use both –config and –genesis.

In that case, the genesis block description provided by –config will be overwritten by the –genesis option.

**Note**

\<filename> contains a JSON description of the network:

* sealEngine (engine use to mine block)
* “Ethash” is the Expanse proof of work engine (used by the live network).
* “NoProof” no proof of work is needed to mine a block.
* params (general network information like minGasLimit, minimumDifficulty, blockReward, networkID)
* genesis (genesis block description)
* accounts (setup an original state that contains accounts/contracts)

Here is a Config sample (used by the Olympic network):

**Note**

\<filename> contains a JSON description of the genesis block:

The content is the same as the genesis field provided by the ‘config’ parameter:

### **GEXP (GO CLIENT)** <a href="#gexp-go-client" id="gexp-go-client"></a>

You either pre-generate or mine your own Expanse on a private testnet. It is a much more cost effective way of trying out Expanse and you can avoid having to mine or find Morden test expanse.

**The things that are required to specify in a private chain are:**

* Custom Genesis File
* Custom Data Directory
* Custom NetworkID
* (Recommended) Disable Node Discovery

#### **THE GENESIS FILE** <a href="#the-genesis-file" id="the-genesis-file"></a>

The genesis block is the start of the blockchain – the first block, block 0, and the only block that does not point to a predecessor block. The protocol ensures that no other node will agree with your version of the blockchain unless they have the same genesis block, so you can make as many private testnet blockchains as you’d like!

CustomGenesis.json

{\
&#x20;  “nonce”: “0x0000000000000042”,     “timestamp”: “0x0”,\
&#x20;  “parentHash”: “0x0000000000000000000000000000000000000000000000000000000000000000”,\
&#x20;  “extraData”: “0x0”,     “gasLimit”: “0x8000000”,     “difficulty”: “0x400”,\
&#x20;  “mixhash”: “0x0000000000000000000000000000000000000000000000000000000000000000”,\
&#x20;  “coinbase”: “0x3333333333333333333333333333333333333333”,     “alloc”: { }\
}

Save a file called CustomGenesis.json. You will reference this when starting your gexp node using the following flag:

–genesis /path/to/CustomGenesis.json

#### **COMMAND LINE PARAMETERS FOR PRIVATE NETWORK** <a href="#command-line-parameters-for-private-network" id="command-line-parameters-for-private-network"></a>

There are some command line options (also called “flags”) that are necessary in order to make sure that your network is private. We already covered the genesis flag, but we need a few more. Note that all of the commands below are to be used in the gexp Expanse client.

–nodiscover

Use this to make sure that your node is not discoverable by people who do not manually add you. Otherwise, there is a chance that your node may be inadvertently added to a stranger’s blockchain if they have the same genesis file and network id.

–maxpeers 0

Use maxpeers 0 if you do not want anyone else connecting to your test chain. Alternatively, you can adjust this number if you know exactly how many peers you want connecting to your node.

–rpc

This will enable RPC interface on your node. This is generally enabled by default in Gexp.

–rpcapi “db,exp,net,web3”

This dictates what APIs that are allowed to be accessed over RPC. By default, Gexp enables the web3 interface over RPC.

**IMPORTANT: Please note that offering an API over the RPC/IPC interface will give everyone access to the API who can access this interface (e.g. dapp’s). Be careful which API’s you enable. By default gexp enables all API’s over the IPC interface and only the db,exp,net and web3 API’s over the RPC interface.**

–rpcport “8080”

Change 8000 to any port that is open on your network. The default for gexp is 8080.

–rpccorsdomain “<http://chriseth.github.io/browser-solidity/”>

This dictates what URLs can connect to your node in order to perform RPC client tasks. Be very careful with this and type a specific URL rather than the wildcard (\*) which would allow any URL to connect to your RPC instance.

–datadir “/home/TestChain1”

This is the data directory that your private chain data will be stored in (under the nubits . Choose a location that is separate from your public Expanse chain folder.

–port “30303”

This is the “network listening port”, which you will use to connect with other peers manually.

–identity “TestnetMainNode”

This will set up an identity for your node so it can be identified more easily in a list of peers. Here is an example of how these identities show up on the network.

#### **LAUNCHING GEXP** <a href="#launching-gexp" id="launching-gexp"></a>

After you have created your custom genesis block JSON file and created a directory for your blockchain data, type the following command into your console that has access to gexp:

gexp –identity “MyNodeName” –genesis /path/to/CustomGenesis.json –rpc –rpcport “8080” –rpccorsdomain “\*” –datadir “C:\chains\TestChain1” –port “30303” –nodiscover –rpcapi “db,exp,net,web3” –networkid 1999 console

**Note**

Please change the flags to match your custom settings.

You will need to start your gexp instance with your custom chain command every time you want to access your custom chain. If you just type “gexp” in your console, it will not remember all of the flags you have set.

#### **PRE-ALLOCATING EXPANSE TO YOUR ACCOUNT** <a href="#pre-allocating-expanse-to-your-account" id="pre-allocating-expanse-to-your-account"></a>

A difficulty of “0x400” allows you to mine Expanse very quickly on your private testnet chain. If you create your chain and start mining, you should have hundreds of Expanse in a matter of minutes which is way more than enough to test transactions on your network. If you would still like to pre-allocate Expanse to your account, you will need to:

1. Create a new Expanse account after you create your private chain
2. Copy your new account address
3. Add the following command to your Custom\_Genesis.json file:

“alloc”:\
{\
&#x20;      “\<your account address e.g. 0x1fb891f92eb557f4d688463d0d7c560552263b5a>”:\
&#x20;      { “balance”: “20000000000000000000” }\
}

**Note**

Replace 0x1fb891f92eb557f4d688463d0d7c560552263b5a with your account address.

Save your genesis file and rerun your private chain command. Once gexp is fully loaded, close it by .

We want to assign an address to the variable primary and check its balance.

Run the command gexp account list in your terminal to see what account # your new address was assigned.

\> gexp account list\
Account #0: {d1ade25ccd3d550a7eb532ac759cac7be09c2719}\
Account #1: {da65665fc30803cb1fb7e6d86691e20b1826dee0}\
Account #2: {e470b1a7d2c9c5c6f03bbaa8fa20db6d404a0c32}\
Account #3: {f4dd5c3794f1fd0cdc0327a83aa472609c806e99}

Take note of which account # is the one that you pre-allocated Expanse to. Alternatively, you can launch the console with gexp console (keep the same parameters as when you launched gexp first). Once the prompt appears, type

\> exp.accounts

This will return the array of account addresses you possess.

\> primary = exp.accounts\[0]

**Note**

Replace 0 with your account’s index. This console command should return your primary Expanse address.

Type the following command:

\> balance = web3.fromWei(exp.getBalance(primary), “expanse”);

This should return 7.5 indicating you have that much Expanse in your account. The reason we had to put such a large number in the alloc section of your genesis file is because the “balance” field takes a number in wei which is the smallest denomination of the Expanse currency Expanse (see Expanse).

* <https://www.reddit.com/r/expanse/comments/3kdnus/question_about_private_chain_mining_dont_upvote/>
* <http://adeduke.com/2015/08/how-to-create-a-private-expanse-chain/>


# Contracts, transactions, account types, and gas

### **EOA VS CONTRACT ACCOUNTS** <a href="#eoa-vs-contract-accounts" id="eoa-vs-contract-accounts"></a>

**There are two types of accounts in Expanse**

* Externally Owned Accounts
* Contracts Accounts

This distinction might be eliminated in Serenity.

#### **EXTERNALLY OWNED ACCOUNTS (EOAS)** <a href="#externally-owned-accounts-eoas" id="externally-owned-accounts-eoas"></a>

An externally controlled account

* has an Expanse balance,
* can send transactions (expanse transfer or trigger contract code),
* is controlled by private keys,
* has no associated code.

#### **CONTRACT ACCOUNTS** <a href="#contract-accounts" id="contract-accounts"></a>

A contract

* has an Expanse balance,
* has associated code,
* code execution is triggered by transactions or messages (calls) received from other contracts.
* when executed – perform operations of arbitrary complexity (Turing completeness) – manipulate its own persistent storage, i.e., can have its own permanent state – can call other contracts

All action on the Expanse block chain is set in motion by transactions fired from externally owned accounts. Every time a contract account receives a transaction, its code is executed as instructed by the input parameters sent as part of the transaction. The contract code is executed by the Expanse Virtual Machine on each node participating in the network as part of their verification of new blocks.

This execution needs to be completely deterministic, its only context is the position of the block on the blockchain and all data available. The blocks on the blockchain represent units of time, the blockchain itself is a temporal dimension and represents the entire history of states at the discrete time points designated by the blocks on the chain.

All Expanse balances and values are denominated in units of wei: 1 Expanse is 1e18 wei.

**Note:** “Contracts” in Expanse should not be seen as something that should be “fulfilled” or “complied with”; rather, they are more like “autonomous agents” that live inside of the Expanse execution environment, always executing a specific piece of code when “poked” by a message or transaction, and having direct control over their own expanse balance and their own key/value store to store their permanent state.

### **WHAT IS A TRANSACTION?** <a href="#what-is-a-transaction" id="what-is-a-transaction"></a>

The term “transaction” is used in Expanse to refer to the signed data package that stores a message to be sent from an externally owned account to another account on the blockchain.

**Transactions contain:**

* the recipient of the message,
* a signature identifying the sender and proving their intention to send the message via the blockchain to the recipient,
* VALUE field – The amount of wei to transfer from the sender to the recipient,
* an optional data field, which can contain the message sent to a contract,
* a STARTGAS value, representing the maximum number of computational steps the transaction execution is allowed to take,
* a GASPRICE value, representing the fee the sender is willing to pay for gas. One unit of gas corresponds to the execution of one atomic instruction, i.e., a computational step.

### **WHAT IS A MESSAGE?** <a href="#what-is-a-message" id="what-is-a-message"></a>

Contracts have the ability to send “messages” to other contracts. Messages are virtual objects that are never serialized and exist only in the Expanse execution environment. They can be conceived of as function calls.

**A message contains:**

* the sender of the message (implicit).
* the recipient of the message
* VALUE field – The amount of wei to transfer alongside the message to the contract address,
* an optional data field, that is the actual input data to the contract
* a STARTGAS value, which limits the maximum amount of gas the code execution triggered by the message can incur.

Essentially, a message is like a transaction, except it is produced by a contract and not an external actor. A message is produced when a contract currently executing code executes the CALL or DELEGATECALLopcodes, which produces and executes a message. Like a transaction, a message leads to the recipient account running its code. Thus, contracts can have relationships with other contracts in exactly the same way that external actors can.

### **WHAT IS GAS?** <a href="#what-is-gas" id="what-is-gas"></a>

Expanse implements an execution environment on the blockchain called the Expanse Virtual Machine (EVM). Every node participating in the network runs the EVM as part of the block verification protocol. They go through the transactions listed in the block they are verifying and run the code as triggered by the transaction within the EVM. Each and every full node in the network does the same calculations and stores the same values. Clearly Expanse is not about optimising efficiency of computation. Its parallel processing is redundantly parallel. This is to offer an efficient way to reach consensus on the system state without needing trusted third parties, oracles or violence monopolies. But importantly they are not there for optimal computation. The fact that contract executions are redundantly replicated across nodes, naturally makes them expensive, which generally creates an incentive not to use the blockchain for computation that can be done offchain.

When you are running a decentralized application (dapp), it interacts with the blockchain to read and modify its state, but dapps will typically only put the business logic and state that are crucial for consensus on the blockchain.

When a contract is executed as a result of being triggered by a message or transaction, every instruction is executed on every node of the network. This has a cost: for every executed operation there is a specified cost, expressed in a number of gas units.

Gas is the name for the execution fee that senders of transactions need to pay for every operation made on an Expanse blockchain. The name gas is inspired by the view that this fee acts as cryptofuel, driving the motion of smart contracts. Gas is purchased for expanse from the miners that execute the code. Gas and expanse are decoupled deliberately since units of gas align with computation units having a natural cost, while the price of expanse generally fluctuates as a result of market forces. The two are mediated by a free market: the price of gas is actually decided by the miners, who can refuse to process a transaction with a lower gas price than their minimum limit. To get gas you simply need to add expanse to your account. The Expanse clients automatically purchase gas for your Expanse in the amount you specify as your maximum expenditure for the transaction.

The Expanse protocol charges a fee per computational step that is executed in a contract or transaction to prevent deliberate attacks and abuse on the Expanse network. Every transaction is required to include a gas limit and a fee that it is willing to pay per gas. Miners have the choice of including the transaction and collecting the fee or not. If the total amount of gas used by the computational steps spawned by the transaction, including the original message and any sub-messages that may be triggered, is less than or equal to the gas limit, then the transaction is processed. If the total gas exceeds the gas limit, then all changes are reverted, except that the transaction is still valid and the fee can still be collected by the miner. All excess gas not used by the transaction execution is reimbursed to the sender as Expanse. You do not need to worry about overspending, since you are only charged for the gas you consume. This means that it is useful as well as safe to send transactions with a gas limit well above the estimates.

### **ESTIMATING TRANSACTION COSTS** <a href="#estimating-transaction-costs" id="estimating-transaction-costs"></a>

The total expanse cost of a transaction is based on 2 factors:

gasUsed is the total gas that is consumed by the transaction

gasPrice price (in expanse) of one unit of gas specified in the transaction

**Total cost = gasUsed \* gasPrice**

#### **GASUSED** <a href="#gasused" id="gasused"></a>

Each operation in the EVM was assigned a number of how much gas it consumes. gasUsed is the sum of all the gas for all the operations executed. There is a [spreadsheet](https://expanse.stackexchange.com/q/52/42) which offers a glimpse to some of the analysis behind this.

For estimating gasUsed, there is an [estimateGas API](https://expanse.stackexchange.com/q/266/42) that can be used but has some caveats.

#### **GASPRICE** <a href="#gasprice" id="gasprice"></a>

A user constructs and signs a transaction, and each user may specify whatever gasPrice they desire, which can be zero. However, the Expanse clients launched at Frontier had a default gasPrice of 0.05e12 wei. As miners optimize for their revenue, if most transactions are being submitted with a gasPrice of 0.05e12 wei, it would be difficult to convince a miner to accept a transaction that specified a lower, or zero, gasPrice.

#### **EXAMPLE TRANSACTION COST** <a href="#example-transaction-cost" id="example-transaction-cost"></a>

Let’s take a contract that just adds 2 numbers. The EVM OPCODE ADD consumes 3 gas.

The approximate cost, using the default gas price (as of January 2016), would be:

3 \* 0.05e12 = 1.5e11 wei

Since 1 Expanse is 1e18 wei, the total cost would be 0.00000015 Expanse.

This is a simplification since it ignores some costs, such as the cost of passing the 2 numbers to contract, before they can even be added.

* [question](https://expanse.stackexchange.com/q/324/42)
* [gas fees](http://expanse.fund/tool/gas-fees)
* [gas cost calculator](http://expanse.fund/tool/calculator)
* [Expanse Gas Prices](https://docs.google.com/spreadsheets/d/1m89CVujrQe5LAFJ8-YAUCcNK950dUzMQPMJBxRtGCqs)

| **Operation Name** | **Gas Cost** | **Remark**                                   |
| ------------------ | ------------ | -------------------------------------------- |
| step               | 1            | default amount per execution cycle           |
| stop               | 0            | free                                         |
| suicide            | 0            | free                                         |
| sha3               | 20           |                                              |
| sload              | 20           | get from permanent storage                   |
| sstore             | 100          | put into permanent storage                   |
| balance            | 20           |                                              |
| create             | 100          | contract creation                            |
| call               | 20           | initiating a read-only call                  |
| memory             | 1            | every additional word when expanding memory  |
| txdata             | 5            | every byte of data or code for a transaction |
| transaction        | 500          | base fee transaction                         |
| contract creation  | 53000        | changed in homestead from 21000              |

### **ACCOUNT INTERACTIONS EXAMPLE – BETTING CONTRACT** <a href="#account-interactions-example-betting-contract" id="account-interactions-example-betting-contract"></a>

As previously mentioned, there are two types of accounts:

* **Externally owned account (EOAs)**: an account controlled by a private key, and if you own the private key associated with the EOA you have the ability to send expanse and messages from it.
* **Contract**: an account that has its own code, and is controlled by code.

By default, the Expanse execution environment is lifeless; nothing happens and the state of every account remains the same. However, any user can trigger an action by sending a transaction from an externally owned account, setting Expanse’s wheels in motion. If the destination of the transaction is another EOA, then the transaction may transfer some expanse but otherwise does nothing. However, if the destination is a contract, then the contract in turn activates, and automatically runs its code.

The code has the ability to read/write to its own internal storage (a database mapping 32-byte keys to 32-byte values), read the storage of the received message, and send messages to other contracts, triggering their execution in turn. Once execution stops, and all sub-executions triggered by a message sent by a contract stop (this all happens in a deterministic and synchronous order, ie. a sub-call completes fully before the parent call goes any further), the execution environment halts once again, until woken by the next transaction.

Contracts generally serve four purposes:

* Maintain a data store representing something which is useful to either other contracts or to the outside world; one example of this is a contract that simulates a currency, and another is a contract that records membership in a particular organization.
* Serve as a sort of externally-owned account with a more complicated access policy; this is called a “forwarding contract” and typically involves simply resending incoming messages to some desired destination only if certain conditions are met; for example, one can have a forwarding contract that waits until two out of a given three private keys have confirmed a particular message before resending it (ie. multisig). More complex forwarding contracts have different conditions based on the nature of the message sent. The simplest use case for this functionality is a withdrawal limit that is overrideable via some more complicated access procedure. A wallet contract is a good example of this.
* Manage an ongoing contract or relationship between multiple users. Examples of this include a financial contract, an escrow with some particular set of mediators, or some kind of insurance. One can also have an open contract that one party leaves open for any other party to engage with at any time; one example of this is a contract that automatically pays a bounty to whoever submits a valid solution to some mathematical problem, or proves that it is providing some computational resource.
* Provide functions to other contracts, essentially serving as a software library.

Contracts interact with each other through an activity that is alternately called either “calling” or “sending messages”. A “message” is an object containing some quantity of expanse, a byte-array of data of any size, the addresses of a sender and a recipient. When a contract receives a message, it has the option of returning some data, which the original sender of the message can then immediately use. In this way, sending a message is exactly like calling a function.

Because contracts can play such different roles, we expect that contracts will be interacting with each other. As an example, consider a situation where Alice and Bob are betting 100 GavCoin that the temperature in San Francisco will not exceed 35ºC at any point in the next year. However, Alice is very security-conscious, and as her primary account uses a forwarding contract which only sends messages with the approval of two out of three private keys. Bob is paranoid about quantum cryptography, so he uses a forwarding contract which passes along only messages that have been signed with Lamport signatures alongside traditional ECDSA (but because he’s old fashioned, he prefers to use a version of Lamport sigs based on SHA256, which is not supported in Expanse directly).

The betting contract itself needs to fetch data about the San Francisco weather from some contract, and it also needs to talk to the GavCoin contract when it wants to actually send the GavCoin to either Alice or Bob (or, more precisely, Alice or Bob’s forwarding contract). We can show the relationships between the accounts thus:

When Bob wants to finalize the bet, the following steps happen:

1. A transaction is sent, triggering a message from Bob’s EOA to his forwarding contract.
2. Bob’s forwarding contract sends the hash of the message and the Lamport signature to a contract which functions as a Lamport signature verification library.
3. The Lamport signature verification library sees that Bob wants a SHA256-based Lamport sig, so it calls the SHA256 library many times as needed to verify the signature.
4. Once the Lamport signature verification library returns 1, signifying that the signature has been verified, it sends a message to the contract representing the bet.
5. The bet contract checks the contract providing the San Francisco temperature to see what the temperature is.
6. The bet contract sees that the response to the messages shows that the temperature is above 35ºC, so it sends a message to the GavCoin contract to move the GavCoin from its account to Bob’s forwarding contract.

Note that the GavCoin is all “stored” as entries in the GavCoin contract’s database; the word “account” in the context of step 6 simply means that there is a data entry in the GavCoin contract storage with a key for the bet contract’s address and a value for its balance. After receiving this message, the GavCoin contract decreases this value by some amount and increases the value in the entry corresponding to Bob’s forwarding contract’s address. We can see these steps in the following diagram:

### **SIGNING TRANSACTIONS OFFLINE** <a href="#signing-transactions-offline" id="signing-transactions-offline"></a>

\[ Maybe add this to the FAQ and point to the ethkey section of turboethereum guide? ]

* [Resilience Raw Transaction Broadcaster](https://github.com/resilience-me/broadcaster/)


# What is a contract?

A contract is a collection of code (its functions) and data (its state) that resides at a specific address on the Expanse blockchain. Contract accounts are able to pass messages between themselves as well as doing practically Turing complete computation. Contracts live on the blockchain in a Expanse-specific binary format called Expanse Virtual Machine (EVM) bytecode.

Contracts are typically written in some high level language such as [Solidity](https://solidity.readthedocs.org/en/latest/) and then compiled into bytecode to be uploaded on the blockchain.

**See also**

Other languages also exist, notably Serpent and LLL, which are described further in the expanse-high-level-languages section of this documentation.

[Dapp development resources](http://docs.expanse.tech/en/latest/contracts-and-transactions/developer-tools.html#ide-or-development-framework) lists the integrated development environments, developer tools that help you develop in these languages, offering testing, and deployment support among other features.

### **EXPANSE HIGH LEVEL LANGUAGES** <a href="#expanse-high-level-languages" id="expanse-high-level-languages"></a>

Contracts live on the blockchain in an Expanse-specific binary format (EVM bytecode) that is executed by the Expanse Virtual Machine (EVM). However, contracts are typically written in a higher level language and then compiled using the EVM compiler into byte code to be deployed to the blockchain.

Below are the different high level languages developers can use to write smart contracts for Expanse.

#### **SOLIDITY** <a href="#solidity" id="solidity"></a>

Solidity is a language similar to JavaScript which allows you to develop contracts and compile to EVM bytecode. It is currently the flagship language of Expanse and the most popular.

* [Solidity Documentation](https://solidity.readthedocs.org/en/latest/) – Solidity is the flagship Expanse high level language that is used to write contracts.
* [Solidity online realtime compiler](https://expanse.github.io/browser-solidity/)
* [Standardized Contract APIs](https://github.com/expanse-org/wiki/wiki/Standardized_Contract_APIs)
* [Useful Ðapp Patterns](https://github.com/expanse-org/wiki/wiki/Useful-%C3%90app-Patterns) – Code snippets which are useful for Ðapp development.

#### **SERPENT** <a href="#serpent" id="serpent"></a>

Serpent is a language similar to Python which can be used to develop contracts and compile to EVM bytecode. It is intended to be maximally clean and simple, combining many of the efficiency benefits of a low-level language with ease-of-use in programming style, and at the same time adding special domain-specific features for contract programming. Serpent is compiled using LLL.

* [Serpent on the expanse wiki](https://github.com/expanse-org/wiki/wiki/Serpent)
* [Serpent EVM compiler](https://github.com/expanse-org/serpent)

#### **LLL** <a href="#lll" id="lll"></a>

[Lisp Like Language (LLL)](https://github.com/expanse-org/libethereum/tree/develop/liblll) is a low level language similar to Assembly. It is meant to be very simple and minimalistic; essentially just a tiny wrapper over coding in EVM directly.

* [LIBLLL in GitHub](https://github.com/expanse-org/libethereum/tree/develop/liblll)
* [Examples of LLL](https://www.reddit.com/r/expanse/comments/3secu1/anyone_have_a_copy_of_the_old_lll_tutorials/)

#### **MUTAN (DEPRECATED)** <a href="#mutan-deprecated" id="mutan-deprecated"></a>

[Mutan](https://github.com/obscuren/mutan) is a statically typed, C-like language designed and developed by Jeffrey Wilcke. It is no longer maintained.

### **WRITING A CONTRACT** <a href="#writing-a-contract" id="writing-a-contract"></a>

No language would be complete without a Hello World program. Operating within the Expanse environment, Solidity has no obvious way of “outputting” a string. The closest we can do is to use a log event to place a string into the blockchain:

contract HelloWorld {\
&#x20;      event Print(string out);\
&#x20;      function() { Print(“Hello, World!”); }\
}

This contract will create a log entry on the blockchain of type Print with a parameter “Hello, World!” each time it is executed.

**See also**

[Solidity docs](https://solidity.readthedocs.org/en/latest/) has more examples and guidelines to writing Solidity code.

### **COMPILING A CONTRACT** <a href="#compiling-a-contract" id="compiling-a-contract"></a>

Compilation of solidity contracts can be accomplished via a number of mechanisms.

* Using the solc compiler via the command line.
* Using web3.exp.compile.solidity in the javascript console provided by gexp or exp (This still requires the solc compiler to be installed).
* The [online Solidity realtime compiler](https://expanse.github.io/browser-solidity/).
* The [Meteor dapp Cosmo for building solidity contracts](https://github.com/SilentCicero/meteor-dapp-cosmo).
* The [Mix IDE](https://github.com/expanse-org/wiki/wiki/Mix:-The-DApp-IDE).
* The [Expanse Wallet](https://github.com/expanse-org/mist/releases).

**Note**

More information on solc and compiling Solidity contract code can be found [here](https://solidity.readthedocs.org/en/latest/frequently-asked-questions.html#how-do-i-compile-contracts).

#### **SETTING UP THE SOLIDITY COMPILER IN GEXP** <a href="#setting-up-the-solidity-compiler-in-gexp" id="setting-up-the-solidity-compiler-in-gexp"></a>

If you start up your gexp node, you can check which compilers are available.

\> web3.exp.getCompilers();\
\[“lll”, “solidity”, “serpent”]

This command returns an array of strings indicating which compilers are currently available.

**Note**

The solc compiler is installed with cpp-expanse. Alternatively, you can [build it yourself](https://github.com/expanse-org/go-expanse/wiki/Building-Expanse).

If your solc executable is in a non-standard location you can specify a custom path to the solcexecutable using th –solc flag.

$ gexp –solc /usr/local/bin/solc

Alternatively, you can set this option at runtime via the console:

\> admin.setSolc(“/usr/local/bin/solc”)\
solc, the solidity compiler commandline interface\
Version: 0.2.2-02bb315d/.-Darwin/appleclang/JIT linked to libethereum-1.2.0-8007cef0/.-Darwin/appleclang/JIT\
path: /usr/local/bin/solc

#### **COMPILING A SIMPLE CONTRACT** <a href="#compiling-a-simple-contract" id="compiling-a-simple-contract"></a>

Let’s compile a simple contract source:

\> source = “contract test { function multiply(uint a) returns(uint d) { return a \* 7; } }”

This contract offers a single method **multiply** which is called with a positive integer a and returns a \* 7.

You are ready to compile solidity code in the gexp JS console using [exp.compile.solidity()](https://github.com/expanse-org/wiki/wiki/JavaScript-API#web3ethcompilesolidity):

\> contract = exp.compile.solidity(source).test\
{\
&#x20;code: ‘605280600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b60376004356041565b8060005260206000f35b6000600782029050604d565b91905056’,\
&#x20;info: {\
&#x20;  language: ‘Solidity’,\
&#x20;  languageVersion: ‘0’,\
&#x20;  compilerVersion: ‘0.9.13’,\
&#x20;  abiDefinition: \[{\
&#x20;    constant: false,\
&#x20;    inputs: \[{\
&#x20;      name: ‘a’,\
&#x20;      type: ‘uint256’\
&#x20;    } ],\
&#x20;    name: ‘multiply’,\
&#x20;    outputs: \[{\
&#x20;      name: ‘d’,\
&#x20;      type: ‘uint256’\
&#x20;    } ],\
&#x20;    type: ‘function’\
&#x20;  } ],\
&#x20;  userDoc: {\
&#x20;    methods: {\
&#x20;    }\
&#x20;  },\
&#x20;  developerDoc: {\
&#x20;    methods: {\
&#x20;    }\
&#x20;  },\
&#x20;  source: ‘contract test { function multiply(uint a) returns(uint d) { return a \* 7; } }’\
&#x20;}\
}

**Note**

The compiler is also available via [RPC](https://github.com/expanse-org/wiki/wiki/JSON-RPC) and therefore via [web3.js](https://github.com/expanse-org/wiki/wiki/JavaScriptAPI#web3ethcompilesolidity) to any in-browser Ðapp connecting to gexp via RPC/IPC.

The following example shows how you interface gexp via JSON-RPC to use the compiler.

$ gexp –datadir \~/exp/ –loglevel 6 –logtostderr=true –rpc –rpcport 8100 –rpccorsdomain ‘\*’ –mine console  2>> \~/exp/exp.log\
$ curl -X POST –data ‘{“jsonrpc”:”2.0″,”method”:”exp\_compileSolidity”,”params”:\[“contract test { function multiply(uint a) returns(uint d) { return a \* 7; } }”],”id”:1}’ <http://127.0.0.1:8100>

The compiler output for one source will give you contract objects each representing a single contract. The actual return value of exp.compile.solidity is a map of contract name to contract object pairs. Since our contract’s name is test, exp.compile.solidity(source).test will give you the contract object for the test contract containing the following fields:

**code**

The compiled EVM bytecode

**info**

Additional metadata output from the compiler

**source**

The source code

**language**

The contract language (Solidity, Serpent, LLL)

**languageVersion**

The contract language version

**compilerVersion**

The solidity compiler version that was used to compile this contract.

**abiDefinition**

The [Application Binary Interface Definition](https://github.com/expanse-org/wiki/wiki/Expanse-Contract-ABI)

**userDoc**

The [NatSpec Doc](https://github.com/expanse-org/wiki/wiki/Expanse-Natural-Specification-Format) for users.

**developerDoc**

The [NatSpec Doc](https://github.com/expanse-org/wiki/wiki/Expanse-Natural-Specification-Format) for developers.

The immediate structuring of the compiler output (into code and info) reflects the two very different **paths of deployment**. The compiled EVM code is sent off to the blockchain with a contract creation transaction while the rest (info) will ideally live on the decentralised cloud as publicly verifiable metadata complementing the code on the blockchain.

If your source contains multiple contracts, the output will contain an entry for each contact, the corresponding contract info object can be retrieved with the name of the contract as attribute name. You can try this by inspecting the most current GlobalRegistrar code:

contracts **=** ex&#x70;**.**&#x63;ompil&#x65;**.**&#x73;olidity(globalRegistrarSrc)

### **CREATE AND DEPLOY A CONTRACT** <a href="#create-and-deploy-a-contract" id="create-and-deploy-a-contract"></a>

Before you begin this section, make sure you have both an unlocked account as well as some funds.

You will now create a contract on the blockchain by [sending a transaction](https://github.com/expanse-org/wiki/wiki/JavaScript-API#web3ethsendtransaction) to the empty address with the EVM code from the previous section as data.

**Note**

This can be accomplished much easier using the [online Solidity realtime compiler](https://expanse.github.io/browser-solidity/) or the [Mix IDE](https://github.com/expanse-org/wiki/wiki/Mix:-The-DApp-IDE)program.

var primaryAddress = exp.accounts\[0]\
var abi = \[{ constant: false, inputs: \[{ name: ‘a’, type: ‘uint256’ } ]\
var MyContract = exp.contract(abi)\
var contract = MyContract.new(arg1, arg2, …, {from: primaryAddress, data: evmByteCodeFromPreviousSection})

All binary data is serialised in hexadecimal form. Hex strings always have a hex prefix 0x.

**Note**

Note that arg1, arg2, … are the arguments for the contract constructor, in case it accepts any. If the contract does not require any constructor arguments then these arguments can be omitted.

It is worth pointing out that this step requires you to pay for execution. Your balance on the account (that you put as sender in the from field) will be reduced according to the gas rules of the EVM once your transaction makes it into a block. After some time, your transaction should appear included in a block confirming that the state it brought about is a consensus. Your contract now lives on the blockchain.

The asynchronous way of doing the same looks like this:

MyContract.**new**(\[arg1, arg2, …,]{fro&#x6D;**:** primaryAccount, dat&#x61;**:** evmCode}, **function**(err, contract) {\
&#x20;**if** (**!**&#x65;rr **&&** contract.address)\
&#x20;  console.log(contract.address);\
});

### **INTERACTING WITH A CONTRACT** <a href="#interacting-with-a-contract" id="interacting-with-a-contract"></a>

Interaction with a contract is typically done using an abstraction layer such as the [exp.contract()](https://github.com/expanse-org/wiki/wiki/JavaScript-API#web3ethcontract)function which returns a javascript object with all of the contract functions available as callable functions in javascript.

The standard way to describe the available functions of a contract is the [ABI definition](https://github.com/expanse-org/wiki/wiki/Expanse-Contract-ABI). This object is an array which describles the call signature and return values for each available contract function.

**var** Multiply7 **=** exp.contract(contract.info.abiDefinition);\
**var** myMultiply7 **=** Multiply7.at(address);

Now all the function calls specified in the ABI are made available on the contract instance. You can just call those methods on the contract instance in one of two ways.

**>** myMultiply7.multiply.sendTransaction(3, {fro&#x6D;**:** address})\
“0x12345”\
**>** myMultiply7.multiply.call(3)\
21

When called using sendTransaction the function call is executed via sending a transaction. This will cost expanse to send and the call will be recorded forever on the blockchain. The return value of calls made in this manner is the hash of the stransaction.

When called using call the function is executed locally in the EVM and the return value of the function is returned with the function. Calls made in this manner are not recorded on the blockchain and thus, cannot modify the internal state of the contract. This manner of call is referred to as a **constant** function call. Calls made in this manner do not cost any expanse.

You should use call if you are interested only in the return value and use sendTransaction if you only care about side effects on the state of the contract.

In the example above, there are no side effects, therefore sendTransaction only burns gas and increases the entropy of the universe.

### **CONTRACT METADATA** <a href="#contract-metadata" id="contract-metadata"></a>

In the previous sections we explained how you create a contract on the blockchain. Now we will deal with the rest of the compiler output, the **contract metadata** or contract info.

When interacting with a contract you did not create you might want documentation or to look at the source code. Contract authors are encouraged to make such information available by registering it on the blockchain or through a third party service, such as [EtherChain](https://www.etherchain.org/contracts). The admin API provides convenience methods to fetch this bundle for any contract that chose to register.

// get the contract info for contract address to do manual verification\
var info = admin.getContractInfo(address) // lookup, fetch, decode\
var source = info.source;\
var abiDef = info.abiDefinition

The underlying mechanism that makes this work is is that:

* contract info is uploaded somewhere identifiable by a URI which is publicly accessible
* anyone can find out what the URI is only knowing the contracts address

These requirements are achieved using a 2 step blockchain registry. The first step registers the contract code (hash) with a content hash in a contract called HashReg. The second step registers a url with the content hash in the UrlHint contract. These [registry contracts](https://github.com/expanse-org/go-expanse/blob/develop/common/registrar/contracts.go) were part of the Frontier release and have carried on into Homestead.

By using this scheme, it is sufficient to know a contract’s address to look up the url and fetch the actual contract metadata info bundle.

So if you are a conscientious contract creator, the steps are the following:

1. Deploy the contract itself to the blockchain
2. Get the contract info json file.
3. Deploy contract info json file to any url of your choice
4. Register codehash ->content hash -> url

The JS API makes this process very easy by providing helpers. Call admin.register to extract info from the contract, write out its json serialisation in the given file, calculates the content hash of the file and finally registers this content hash to the contract’s code hash. Once you deployed that file to any url, you can use admin.registerUrl to register the url with your content hash on the blockchain as well. (Note that in case a fixed content addressed model is used as document store, the url-hint is no longer necessary.)

source **=** “contract test { function multiply(uint a) returns(uint d) { return a \* 7; } }”\
// compile with solc\
contract **=** exp.compile.solidity(source).test\
// create contract object\
**var** MyContract **=** exp.contract(contract.info.abiDefinition)\
// extracts info from contract, save the json serialisation in the given file,\
contenthash **=** admin.saveInfo(contract.info, “\~/dapps/shared/contracts/test/info.json”)\
// send off the contract to the blockchain\
MyContract.**new**({fro&#x6D;**:** primaryAccount, dat&#x61;**:** contract.code}, **function**(error, contract){\
&#x20;**if**(**!**&#x65;rror **&&** contract.address) {\
&#x20;  // calculates the content hash and registers it with the code hash in \`HashReg\`\
&#x20;  // it uses address to send the transaction.\
&#x20;  // returns the content hash that we use to register a url\
&#x20;  admin.register(primaryAccount, contract.address, contenthash)\
&#x20;  // here you deploy \~/dapps/shared/contracts/test/info.json to a url\
&#x20;  admin.registerUrl(primaryAccount, hash, url)\
&#x20;}\
});

### **TESTING CONTRACTS AND TRANSACTIONS** <a href="#testing-contracts-and-transactions" id="testing-contracts-and-transactions"></a>

Often you need to resort to a low level strategy of testing and debugging contracts and transactions. This section introduces some debug tools and practices you can use. In order to test contracts and transactions without real-word consequences, you best test it on a private blockchain. This can be achieved with configuring an alternative network id (select a unique integer) and/or disable peers. It is recommended practice that for testing you use an alternative data directory and ports so that you never even accidentally clash with your live running node (assuming that runs using the defaults. Starting your gexp with in VM debug mode with profiling and highest logging verbosity level is recommended:

gexp –datadir \~/dapps/testing/00/ –port 30310 –rpcport 8110 –networkid 4567890 –nodiscover –maxpeers 0 –vmdebug –verbosity 6 –pprof –pprofport 6110 console 2>> \~/dapp/testint/00/00.log

Before you can submit any transactions, you need set up your private test chain. See [Test Networks](http://docs.expanse.tech/en/latest/network/test-networks.html#test-networks).

// create account. will prompt for password\
personal.newAccount();\
// name your primary account, will often use it\
primary = exp.accounts\[0];\
// check your balance (denominated in expanse)\
balance = web3.fromWei(exp.getBalance(primary), “expanse”);

// assume an existing unlocked primary account\
primary = exp.accounts\[0];\
\
// mine 10 blocks to generate expanse\
\
// starting miner\
miner.start(4);\
// sleep for 10 blocks (this can take quite some time).\
admin.sleepBlocks(10);\
// then stop mining (just not to burn heat in vain)\
miner.stop();\
balance = web3.fromWei(exp.getBalance(primary), “expanse”);

After you create transactions, you can force process them with the following lines:

mine&#x72;**.**&#x73;tart(1);\
admi&#x6E;**.**&#x73;leepBlocks(1);\
mine&#x72;**.**&#x73;top();

You can check your pending transactions with:

// shows transaction pool\
txpool.status\
// number of pending txs\
exp.getBlockTransactionCount(“pending”);\
// print all pending txs\
exp.getBlock(“pending”, true).transactions

If you submitted contract creation transaction, you can check if the desired code actually got inserted in the current blockchain:

txhash = exp.sendTansaction({from:primary, data: code})\
//… mining\
contractaddress = exp.getTransactionReceipt(txhash);\
exp.getCode(contractaddress)


# Accessing contracts and transactions

### **RPC** <a href="#rpc" id="rpc"></a>

In previous sections we have seen how contracts can be written, deployed and interacted with. Now it’s time to dive in the details of communicating with the Expanse network and smart contracts.

An Expanse node offers a [RPC](https://wikipedia.org/wiki/Remote_procedure_call) interface. This interface gives Ðapp’s access to the Expanse blockchain and functionality that the node provides, such as compiling smart contract code. It uses a subset of the [JSON-RPC 2.0](http://www.jsonrpc.org/specification) specification (no support for notifications or named parameters) as serialisation protocol and is available over HTTP and IPC (unix domain sockets on linux/OSX and named pipe’s 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](http://docs.expanse.tech/en/latest/contracts-and-transactions/accessing-contracts-and-transactions.html#using-web3-js).

**Conventions**

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 prevent these 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](https://github.com/expanse-org/wiki/wiki/JSON-RPC#output-hex-values) on the wiki for examples.
* Default block number, several RPC methods accept a block number. In some cases it’s not possible to give a block number or not very convenient. For these cases the default block number can be one of these strings \[“earliest”, “latest”, “pending”]. See the [wiki page](https://github.com/expanse-org/wiki/wiki/JSON-RPC#the-default-block-parameter) for a list of RPC methods that use the default block parameters.

### **DEPLOY CONTRACT** <a href="#deploy-contract" id="deploy-contract"></a>

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 interface is enabled. This means for gexp we supply the –rpc flag on startup and for exp the -j flag. In this example we use the gexp node on a private development chain. Using this approach we don’t need expanse on the real network.

`gexp --rpc --dev --mine --minerthreads 1 --unlock 0 console 2>>gexp.log`

This will start the HTTP RPC interface on <http://localhost:8545>.

**Note**

`gexp supports` [`CORS`](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)`, see the --rpccorsdomain flag for more information.`

We can verify that the interface is running by retrieving the coinbase address and balance using [curl](https://curl.haxx.se/download.html). Please note that data in these examples will differ on your local node. If you want to try these command replace the request params accordingly.

`curl --data '{"jsonrpc":"2.0","method":"exp_coinbase", "id":1}' localhost:8545`\
`{"id":1,"jsonrpc":"2.0","result":["0xeb85a5557e5bdc18ee1934a89d8bb402398ee26a"]}`

curl –data ‘{“jsonrpc”:”2.0″,”method”:”exp\_getBalance”, “params”: \[“0xeb85a5557e5bdc18ee1934a89d8bb402398ee26a”], “id”:2}’ localhost:8545\
{“id”:2,”jsonrpc”:”2.0″,”result”:”0x1639e49bba16280000″}

Remember when we said that numbers are hex encoded? In this case the balance is returned in Wei as a hex string. If we want to have the balance in Expanse as a number we can use web3 from the gexp console.

`web3.fromWei("0x1639e49bba16280000", "expanse")`\
`"410"`

Now that we have some expanse on our private development chain we can deploy the contract. The first step is to verify that the solidity compiler is available. We can retrieve available compilers using the exp\_getCompilers RPC method.

`"curl --data '{"jsonrpc":"2.0","method": "exp_getCompilers", "id": 3}' localhost:8545`\
`{"id":3,"jsonrpc":"2.0","result":["Solidity"]}"`

We can see that the solidity compiler is available. If it’s not available follow [these](https://solidity.readthedocs.org/en/latest/installing-solidity.html) instructions.

The next step is to compile the Multiply7 contract to byte code that can be send to the EVM.

`"curl --data '{"jsonrpc":"2.0","method": "exp_compileSolidity", "params": ["contract Multiply7 { event Print(uint); function multiply(uint input) returns (uint) { Print(input * 7); return input * 7; } }"], "id": 4}' localhost:8545`\
`{"id":4,"jsonrpc":"2.0","result":{"Multiply7":{"code":"0x6060604052605f8060106000396000f3606060405260e060020a6000350463c6888fa18114601a575b005b60586004356007810260609081526000907f24abdb5865df5079dcc5ac590ff6f01d5c16edbc5fab4e195d9febd1114503da90602090a15060070290565b5060206060f3","info":{"source":"contract Multiply7 { event Print(uint); function multiply(uint input) returns (uint) { Print(input * 7); return input * 7; } }","language":"Solidity","languageVersion":"0.2.2","compilerVersion":"0.2.2","compilerOptions":"--bin --abi --userdoc --devdoc --add-std --optimize -o /tmp/solc205309041","abiDefinition":[{"constant":false,"inputs":[{"name":"input","type":"uint256"}],"name":"multiply","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"","type":"uint256"}],"name":"Print","type":"event"}],"userDoc":{"methods":{}},"developerDoc":{"methods":{}}}}}}"`

Now that we have the compiled code we need to determine how much gas it costs to deploy it. The RPC interface has an exp\_estimateGas method that will give us an estimate.

`"curl --data '{"jsonrpc":"2.0","method": "exp_estimateGas", "params": [{"from": "0xeb85a5557e5bdc18ee1934a89d8bb402398ee26a", "data": "0x6060604052605f8060106000396000f3606060405260e060020a6000350463c6888fa18114601a575b005b60586004356007810260609081526000907f24abdb5865df5079dcc5ac590ff6f01d5c16edbc5fab4e195d9febd1114503da90602090a15060070290565b5060206060f3"}], "id": 5}' localhost:8545`\
`{"id":5,"jsonrpc":"2.0","result":"0xb8a9"}"`

And finally deploy the contract.

`"curl --data '{"jsonrpc":"2.0","method": "exp_sendTransaction", "params": [{"from": "0xeb85a5557e5bdc18ee1934a89d8bb402398ee26a", "gas": "0xb8a9", "data": "0x6060604052605f8060106000396000f3606060405260e060020a6000350463c6888fa18114601a575b005b60586004356007810260609081526000907f24abdb5865df5079dcc5ac590ff6f01d5c16edbc5fab4e195d9febd1114503da90602090a15060070290565b5060206060f3"}], "id": 6}' localhost:8545`\
`{"id":6,"jsonrpc":"2.0","result":"0x3a90b5face52c4c5f30d507ccf51b0209ca628c6824d0532bcd6283df7c08a7c"}"`

The transaction is accepted by the node and a transaction hash is returned. We can use this hash to track the transaction.

The next step is to determine the address where our contract is deployed. Each executed transaction will create a receipt. This receipt contains various information about the transaction such as in which block the transaction was included and how much gas was used by the EVM. If a transaction creates a contract it will also contain the contract address. We can retrieve the receipt with the exp\_getTransactionReceipt RPC method.

`"curl --data '{"jsonrpc":"2.0","method": "exp_getTransactionReceipt", "params": ["0x3a90b5face52c4c5f30d507ccf51b0209ca628c6824d0532bcd6283df7c08a7c"], "id": 7}' localhost:8545`\
`{"id":7,"jsonrpc":"2.0","result":{"transactionHash":"0x3a90b5face52c4c5f30d507ccf51b0209ca628c6824d0532bcd6283df7c08a7c","transactionIndex":"0x0","blockNumber":"0x4c","blockHash":"0xe286656e478a1b99030e318d0f5c3a61a644f25e63deaa8be52e80da1e7b0c47","cumulativeGasUsed":"0xb8a9","gasUsed":"0xb8a9","contractAddress":"0x6ff93b4b46b41c0c3c9baee01c255d3b4675963d","logs":[]}}"`

We can see that our contract was created on 0x6ff93b4b46b41c0c3c9baee01c255d3b4675963d. If you got null instead of a receipt the transaction has not been included in a block yet. Wait for a moment and check if your miner is running and retry it.

### **INTERACTING WITH SMART CONTRACTS** <a href="#interacting-with-smart-contracts" id="interacting-with-smart-contracts"></a>

Now that our contract is deployed we can interact with it. There are 2 methods for this, sending a transaction or [using call as previously explained](http://docs.expanse.tech/en/latest/contracts-and-transactions/contracts.html#interacting-with-a-contract). In this example we will be sending a transaction to the multiply method of the contract.

If we look at the documentation for the [exp\_sendTransaction](https://github.com/expanse-org/wiki/wiki/JSON-RPC#exp_sendtransaction) we can see that we need to supply several arguments. In our case we need to specify the from, to and data arguments. From is the public address of our account and to the contract address. The data argument is a bit harder. It contains a payload that defines which method must be called and with which arguments. This is were the ABI comes into play. The ABI defines how to define and encode data for the EVM. You can read[all the details about the ABI here](https://github.com/expanse-org/wiki/wiki/Expanse-Contract-ABI).

The bytes of the payload is the function selector and defines which method is called. This is done by taking the first 4 bytes from the Keccak hash over the function name and its argument types and hex encode it. The multiply function accepts an uint which is an [alias](https://solidity.readthedocs.org/en/latest/types.html#integers) for uint256. This leaves us with:

`web3.sha3("multiply(uint256)").substring(0, 8)`\
`"c6888fa1"`

See for details [this page](https://github.com/expanse-org/wiki/wiki/Expanse-Contract-ABI#function-selector).

The next step is to encode the arguments. We only have one uint256, lets assume we supply the value 6. The ABI has a [section](https://github.com/expanse-org/wiki/wiki/Expanse-Contract-ABI#argument-encoding) which specifies how to encode uint256 types.

int\<M>: enc(X) is the big-endian two’s complement encoding of X, padded on the higher-oder (left) side with 0xff for negative X and with zero bytes for positive X such that the length is a multiple of 32 bytes.

This encodes to 0000000000000000000000000000000000000000000000000000000000000006.

Combining the function selector and the encoded argument our data will be 0xc6888fa10000000000000000000000000000000000000000000000000000000000000006.

Lets try it:

`"curl --data '{"jsonrpc":"2.0","method": "exp_sendTransaction", "params": [{"from": "0xeb85a5557e5bdc18ee1934a89d8bb402398ee26a", "to": "0x6ff93b4b46b41c0c3c9baee01c255d3b4675963d", "data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}], "id": 8}' localhost:8545`\
`{"id":8,"jsonrpc":"2.0","result":"0x759cf065cbc22e9d779748dc53763854e5376eea07409e590c990eafc0869d74"}"`

Since we sent a transaction we got the transaction hash returned. If we retrieve the receipt we can see something new:

`{`\
`blockHash`**`:`**` ``"0xbf0a347307b8c63dd8c1d3d7cbdc0b463e6e7c9bf0a35be40393588242f01d55",`\
`blockNumber`**`:`**` ``268,`\
`contractAddress`**`:`** **`null`**`,`\
`cumulativeGasUsed`**`:`**` ``22631,`\
`gasUsed`**`:`**` ``22631,`\
`logs`**`:`**` ``[{`\
`address`**`:`**` ``"0x6ff93b4b46b41c0c3c9baee01c255d3b4675963d",`\
`blockHash`**`:`**` ``"0xbf0a347307b8c63dd8c1d3d7cbdc0b463e6e7c9bf0a35be40393588242f01d55",`\
`blockNumber`**`:`**` ``268,`\
`data`**`:`**` ``"0x000000000000000000000000000000000000000000000000000000000000002a",`\
`logIndex`**`:`**` ``0,`\
`topics`**`:`**` ``["0x24abdb5865df5079dcc5ac590ff6f01d5c16edbc5fab4e195d9febd1114503da"],`\
`transactionHash`**`:`**` ``"0x759cf065cbc22e9d779748dc53763854e5376eea07409e590c990eafc0869d74",`\
`transactionIndex`**`:`**` ``0`\
`}],`\
`transactionHash`**`:`**` ``"0x759cf065cbc22e9d779748dc53763854e5376eea07409e590c990eafc0869d74",`\
`transactionIndex`**`:`**` ``0`\
`}`

The receipt contains a log. This log was generated by the EVM on transaction execution and included in the receipt. If we look at the multipy function we can see that the Print event was raised with the input times 7. Since the argument for the Print event was a uint256 we can decode it according to the ABI rules which will leave us with the expected decimal 42. Apart from the data it is worth noting that topics can be used to determine which event created the log:

`web3.sha3("Print(uint256)")`\
`"24abdb5865df5079dcc5ac590ff6f01d5c16edbc5fab4e195d9febd1114503da"`

You can read more about events, topics and indexing in the [Solidity tutorial](https://solidity.readthedocs.org/en/latest/contracts.html#events).

This was just a brief introduction into some of the most common tasks. See for a full list of available RPC methods the [RPC wiki page](https://github.com/expanse-org/wiki/wiki/JSON-RPC#json-rpc-methods).

### **WEB3.JS** <a href="#web3-js" id="web3-js"></a>

As we have seen in the previous example using the JSON-RPC interface can be quite tedious and error-prone, especially when we have to deal with the ABI. Web3.js is a javascript library that works on top of the Expanse RPC interface. Its goal is to provide a more user friendly interface and reducing the chance for errors.

Deploying the Multiply7 contract using web3 would look like:

`var source = 'contract Multiply7 { event Print(uint); function multiply(uint input) returns (uint) { Print(input * 7); return input * 7; } }';`\
`var compiled = web3.exp.compile.solidity(source);`\
`var code = compiled.Multiply7.code;`\
`var abi = compiled.Multiply7.info.abiDefinition;`

`web3.exp.contract(abi).new({from: "0xeb85a5557e5bdc18ee1934a89d8bb402398ee26a", data: code}, function (err, contract) {`\
&#x20; `if (!err && contract.address)`\
&#x20;    `console.log("deployed on:", contract.address);`\
&#x20; `}`\
`);`

deployed on: 0x0ab60714033847ad7f0677cc7514db48313976e2

Load a deployed contract and send a transaction:

`var source = 'contract Multiply7 { event Print(uint); function multiply(uint input) returns (uint) { Print(input * 7); return input * 7; } }';`\
`var compiled = web3.exp.compile.solidity(source);`\
`var Multiply7 = web3.exp.contract(compiled.Multiply7.info.abiDefinition);`\
`var multi = Multiply7.at("0x0ab60714033847ad7f0677cc7514db48313976e2")`\
`multi.multiply.sendTransaction(6, {from: "0xeb85a5557e5bdc18ee1934a89d8bb402398ee26a"})`

Register a callback which is called when the Print event created a log.

`multi.Print(function(err, data) { console.log(JSON.stringify(data)) })`\
`{"address":"0x0ab60714033847ad7f0677cc7514db48313976e2","args": {"":"21"},"blockHash":"0x259c7dc07c99eed9dd884dcaf3e00a81b2a1c83df2d9855ce14c464b59f0c8b3","blockNumber":539,"event":"Print","logIndex":0, "transactionHash":"0x5c115aaa5418118457e96d3c44a3b66fe9f2bead630d79455d0ecd832dc88d48","transactionIndex":0}`

See for more information the [web3.js](https://github.com/expanse-org/wiki/wiki/JavaScript-API) wiki page.

### **CONSOLE** <a href="#console" id="console"></a>

The gexp [console](https://github.com/expanse-org/go-expanse/wiki/JavaScript-Console) offers a command line interface with a javascript runtime. It can connect to a local or remote gexp or exp node. It will load the web3.js library that users can use. This allows users to deploy and interact with smart contract from the console using web3.js. In fact the examples in the [Web3.js](http://docs.expanse.tech/en/latest/contracts-and-transactions/accessing-contracts-and-transactions.html#using-web3-js) section can by copied into the console.

### **VIEWING CONTRACTS AND TRANSACTIONS** <a href="#viewing-contracts-and-transactions" id="viewing-contracts-and-transactions"></a>

There are several online blockchain explorers available that will allow you to inspect the Expanse blockchain. See for a list: [Blockchain explorers](http://docs.expanse.tech/en/latest/contracts-and-transactions/accessing-contracts-and-transactions.html#blockchain-explorers).

#### **HOSTED BLOCKCHAIN EXPLORERS** <a href="#hosted-blockchain-explorers" id="hosted-blockchain-explorers"></a>

* [Expanse Explorer](http://www.expanse.tech/explorer/)
* [Expanse Live](https://live.expanse.camp/)

#### **OTHER RESOURCES** <a href="#other-resources" id="other-resources"></a>

* [EXPStats](http://stats.expanse.tech/) – Geographic distribution of nodes and split by client


# What is the IDE Mix?

The IDE Mix is intended to help you as a developer to create, debug and deploy contracts and dapps (both contracts backend and frontend).

**WARNING – There are numerous reports of crash-at-boot issues for Mix on OS X. The issue is a**[Heisenbug](https://en.wikipedia.org/wiki/Heisenbug) **which we have been chasing for a month or two. The best workaround we have for right now is to use the Debug configuration, like so:**

cmake -DCMAKE\_BUILD\_TYPE=Debug ..

**WARNING – A replacement for Mix called** [Remix](https://blog.expanse.tech/2016/05/04/c-dev-update-announcing-remix/) **is being worked on, so if you are experiencing issues with Mix, you might be better to look for alternatives until Remix is more mature.**

Start by creating a new project that consists of

* contracts
* html files
* JavaScript files
* style files
* image files
* [Project Editor](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/project-editor.html)
  * [Creating a new project](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/project-editor.html#creating-a-new-project)
  * [Editing backend contract file](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/project-editor.html#editing-backend-contract-file)
* [Scenarios Editor](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/scenario-editor.html)
  * [Creating and setting up a new scenario](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/scenario-editor.html#creating-and-setting-up-a-new-scenario)
  * [Modifying initial expanse balance of an account](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/scenario-editor.html#modifying-initial-expanse-balance-of-an-account)
  * [Rebuilding a scenario](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/scenario-editor.html#rebuilding-a-scenario)
  * [Creating a transaction](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/scenario-editor.html#creating-a-transaction)
  * [Altering and reusing scenarios](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/scenario-editor.html#altering-and-reusing-scenarios)
  * [Display calls](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/scenario-editor.html#display-calls)
* [State Viewer](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/state-viewer.html)
* [Transaction Explorer](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/transaction-explorer.html)
* [JavaScript console](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/javascript-console.html)
  * [Using the JS console to add transactions and local calls](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/javascript-console.html#using-the-js-console-to-add-transactions-and-local-calls)
* [Transaction debugger](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/transaction-debugger.html)
  * [Accessing the debug mode](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/transaction-debugger.html#accessing-the-debug-mode)
  * [Toggling between debug modes and stepping through transactions](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/transaction-debugger.html#toggling-between-debug-modes-and-stepping-through-transactions)
* [Dapps deployment](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/dapp-deployment.html)
* [Code Editor](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix/codeeditor.html)


# How to create Dapps?

A dapp is service that enables direct interaction between end users and providers (e.g. connecting buyers and sellers in some marketplace, owners and storers in file storage). Expanse dapps typically interface users via an HTML/Javascript web application using a Javascript API to communicate with the blockchain. Dapps would typically have their own suite of associated contracts on the blockchain which they use to encode business logic and allow persistent storage of their consensus-critical state. Remember that because of the redundant nature of computation on the Expanse network, the gas costs of execution will always be higher than private execution offchain. This incentivizes dapp developers to restrict the amount of code they execute and amount of data they store on the blockchain.

### **DAPP DIRECTORIES** <a href="#dapp-directories" id="dapp-directories"></a>

Dapps that use Expanse are compiled to the following lists. They are listed in various stages of development (concept, working prototype, live/deployed). If you are developing a dapp, consider adding an entry to these listings:

* [Ethercasts State of the Ðapps](http://dapps.ethercasts.com/)
* [Dappslist](https://dappslist.com/)
* [Dappcentral](http://dappcentral.io/) – Sortable pages for Dapps with instructions, code validation, and network stats.
* [Dapps Mailing List](http://dapplist.net/) – Mailing list for developers on Expanse (discontinued).

The offered decentralised services listed cover a wide range of areas including finance, insurance, prediction markets, social networks, distributed computation and storage, gambling, marketplace, internet of things, governance, collaboration, development and games.

* What apps can we eventually expect? <https://www.reddit.com/r/expanse/comments/2mnl7f/the_top_10_ether_dapps_of_2015/cm63nsf>

In the future, dapps are likely to be listed and distributed in [dappstores](http://dappstore.io/) integrated in dapp browsers.

### **DAPP BROWSERS** <a href="#dapp-browsers" id="dapp-browsers"></a>

* [Mist](https://github.com/expanse-org/mist) – official GUI dapp browser developed by the foundation, alpha stage. Mist as Wallet dapp is in beta.
* [Syng](http://syng.im/) – Mobile Expanse browser (alpha) by Jarrad Hope – supported by DEVgrants
* [MetaMask](https://metamask.io/) – Aaron Kumavis Davis’s in-browser GUI. [Epicenter Bitcoin interview on github](https://www.reddit.com/r/expanse/comments/3x97rg/aaron_davis_explains_the_differences_between/) – supported by DEVgrants
* [AlethZero](https://github.com/expanse-org/alethzero) – C++ exp client GUI, (discontinued).
* [Supernova](http://www.supernove.cc/) – (discontinued).


# What Developers tools are?

Dapp development requires an understanding of the Web3 Javascript API, the JSON RPC API, and the Solidity programming language.

**Note**

There are developer tools that help you develop, test, and deploy dapps in a way that automatically utilizes the resources listed below.

* [Web3 JavaScript API](https://github.com/expanse-org/wiki/wiki/JavaScript-API) – This is the main JavaScript SDK to use when you want to interact with an Expanse node.
* [JSON RPC API](https://github.com/expanse-org/wiki/wiki/JSON-RPC) – This is the low level JSON RPC 2.0 interface to interface with a node. This API is used by the [Web3 JavaScript API](https://github.com/expanse-org/wiki/wiki/JavaScript-API).
* [Solidity Docs](https://solidity.readthedocs.org/en/latest/) – Solidity is the Expanse developed Smart Contract language, which compiles to EVM (Expanse Virtual Machine) opcodes.
* [Test Networks](http://docs.expanse.tech/en/latest/network/test-networks.html#test-networks) – Test networks help developers develop and test Expanse code and network interactions without spending their own Expanse on the main network. Test network options are listed below.
* [Dapp development resources](http://docs.expanse.tech/en/latest/contracts-and-transactions/developer-tools.html#ide-or-development-framework). This assists you in developing, debugging, and deploying Expanse applications.

### **DAPP DEVELOPMENT RESOURCES** <a href="#dapp-development-resources" id="dapp-development-resources"></a>

* [Smart contracts ELI5](https://www.reddit.com/r/expanse/comments/2cbwak/ethereum_contracts_please_eli5/)
* <https://blog.slock.it/a-primer-to-the-decentralized-autonomous-organization-dao-69fb125bd3cd>
* [A 101 noob’s intro to programming smart contracts](https://www.reddit.com/r/expanse/comments/44vs8b/a_101_noob_intro_to_programming_smart_contracts/)
* [Standardised contract APIs listing](https://www.reddit.com/r/expanse/comments/3k3jha/reminder_standardized_contract_apis_listing/)

#### **EXAMPLES** <a href="#examples" id="examples"></a>

* [example use of pricefeed – web3 script printing all account balances](https://gist.github.com/larspensjo/ffd2e4d41f739dc5af54)
* [Example Expanse contracts](https://github.com/drupalnomad/expanse-contracts)

<https://dappsforbeginners.wordpress.com/tutorials/your-first-dapp/>

<https://github.com/expanse-org/wiki/wiki/Dapp-Developer-Resources>

#### **TUTORIALS** <a href="#tutorials" id="tutorials"></a>

* [Dapp tutorials on expanse.tech](https://expanse.tech/)
* [Dapps for beginners tutorial series](https://dappsforbeginners.wordpress.com/)
* [Eris’ Solidity Tutorial Series](https://docs.erisindustries.com/tutorials/solidity/)
* [Tutorials on advanced Solidity](https://github.com/androlo/solidity-workshop)
* <http://ethereumj.io/blog/2015/09/09/friendly-expanse-bot/>
* <https://github.com/ConsenSys/expanse-pudding>

### **MIX-IDE** <a href="#mix-ide" id="mix-ide"></a>

Mix is the official Expanse IDE that allows developers to build and deploy contracts and decentralized applications on top of the Expanse blockchain. It includes a Solidity source code debugger. [Mix](http://docs.expanse.tech/en/latest/contracts-and-transactions/mix.html#sec-mix)

### **IDES/FRAMEWORKS** <a href="#ides-frameworks" id="ides-frameworks"></a>

Below are developer frameworks and IDEs used for writing Expanse dapps.

* [Truffle](https://github.com/ConsenSys/truffle) – Truffle is a development environment, testing framework and asset pipeline for Expanse.
* [Dapple](https://github.com/nexusdev/dapple) – Dapple is a tool for Solidity developers to help build and manage complex contract systems on Expanse-like blockchains.
* [Populus](https://populus.readthedocs.org/en/latest/) – Populus is a Smart Contract development framework written in python.
* [Eris-PM](https://docs.erisindustries.com/documentation/eris-package-manager/) – The Eris Package Manager deploys and tests smart contract systems on private and public chains.
* [Embark](https://iurimatias.github.io/embark-framework/) – Embark is a Ðapp development framework written in JavaScript.
* [EtherScripter (obsolete, discontinued)](http://etherscripter.com/0-5-1/)
* [Resilience Raw Transaction Broadcaster](https://github.com/resilience-me/broadcaster/)

### **EXPANSE-CONSOLE** <a href="#expanse-console" id="expanse-console"></a>

Commandline console for Expanse nodes.

[Ethconsole](https://github.com/expanse-org/expanse-console) connects to an Expanse node running in the background (tested with exp and gexp) via IPC and provides an interactive javascript console containing the web3 object with admin additions.

Here you could find a list of available commands [expanse node control commands](https://github.com/expanse-org/expanse-console/blob/master/web3Admin.js)

To use this console you would need to start a local expanse node with ipc communication socket enabled (file gexp.ipc in data directory). By default ipc socket should be located at you local home directory in .expanse after you started a node. You could also set –test option to use specific node test commands.

In the console you could then type

Here the defenition of –test mode node commands:

More information about node [configuration](http://docs.expanse.tech/en/latest/network/test-networks.html#custom-networks-exp) file.

### **BASE LAYER SERVICES** <a href="#base-layer-services" id="base-layer-services"></a>

#### **WHISPER** <a href="#whisper" id="whisper"></a>

* [What is Whisper and what is it used for](https://expanse.stackexchange.com/questions/127/what-is-whisper-and-what-is-it-used-for) – stackexchange Q\&A
* [Gavin Wood: Shh! Whisper](https://www.youtube.com/watch?v=U_nPoBVLPiw) – DEVCON-1 talk youtube video
* [Whisper overview and dream API usage](https://github.com/expanse-org/wiki/wiki/Whisper-Overview) –
* [ELI5](https://www.reddit.com/r/expanse/comments/2xzm5w/whisper_explain_to_me_like_im_5/)

#### **SWARM** <a href="#swarm" id="swarm"></a>

Swarm is a distributed storage platform and content distribution service, a native base layer service of the Expanse web 3 stack. The primary objective of Swarm is to provide a sufficiently decentralized and redundant store of Expanse’s public record, in particular to store and distribute dapp code and data as well as block chain data. From an economic point of view, it allows participants to efficiently pool their storage and bandwidth resources in order to provide the aforementioned services to all participants.

From the end user’s perspective, Swarm is not that different from WWW, except that uploads are not to a specific server. The objective is to peer-to-peer storage and serving solution that is DDOS-resistant, zero-downtime, fault-tolerant and censorship-resistant as well as self-sustaining due to a built-in incentive system which uses peer to peer accounting and allows trading resources for payment. Swarm is designed to deeply integrate with the devp2p multiprotocol network layer of Expanse as well as with the Expanse blockchain for domain name resolution, service payments and content availability insurance.

**ÐΞVcon talks on swarm**

* [Viktor Trón, Daniel A. Nagy: Swarm](https://www.youtube.com/watch?v=VOC45AgZG5Q) – Expanse ÐΞVcon-1 talk on youtube
* [Daniel A. Nagy: Keeping the Public Record Safe and Accessible](https://www.youtube.com/watch?v=QzYZQ03ON2o\&list=PLJqWcTqh_zKEjpSej3ddtDOKPRGl_7MhS) – Expanse ÐΞVcon-0 talk on youtube

**Code and status**

* \[source]\(<https://github.com/expanse-org/go-expanse/tree/swarm>)
* \[issues on github]\(<https://github.com/expanse-org/go-expanse/labels/swarm>)
* \[development roadmap]\()
* [ethersphere on twitter](https://twitter.com/ethersphere)
* [swarm gitter room](https://gitter.im/expanse/swarm)
* [swarm subreddit](https://reddit.com/r/bzz)

Storage on and offchain

* <https://www.reddit.com/r/expanse/comments/3hkv2f/eli5_storage_in_the_ethereum_blockchain/>
* <https://www.reddit.com/r/expanse/comments/3npsoz/ethereum_ipfs_and_filecoin/>
* [What is swarm and what is it used for?](https://expanse.stackexchange.com/questions/375/what-is-swarm-and-what-is-it-used-for) – stackexchange Q\&A

#### **EXPANSE ALARM CLOCK** <a href="#expanse-alarm-clock" id="expanse-alarm-clock"></a>

* **Author:** Piper Merriam
* **Website:** [alarm\_main\_website](http://www.expanse-alarm-clock.com/).
* **Documentation:** [alarm\_documentation](http://docs.expanse-alarm-clock.com/).

A marketplace that facilitates scheduling transactions to occur at a later time. Serves a similar role to things like crontab in unix, or setTimeout in javascript.

* [Decentralized cron service in Expanse proposal](https://gist.github.com/karalabe/0ab4d715a81b74dd257d) – by Peter Szilagyi

#### **EXPANSE COMPUTATION MARKET** <a href="#expanse-computation-market" id="expanse-computation-market"></a>

* **Author:** Piper Merriam
* **Website:** [computation\_market\_main\_website](http://www.expanse-computation-market.com/).
* **Documentation:** [computation\_market\_documentation](http://docs.expanse-computation-market.com/).

A marketplace that facilitates verifiable execution of computations off-chain. Allows for very expernsive computations to be used within the EVM without having to actually pay the high gas costs of executing them on-chain.

#### **BTCRELAY** <a href="#btcrelay" id="btcrelay"></a>

[**BTCrelay**](http://btcrelay.org/)

* [More information](https://medium.com/@ConsenSys/taking-stock-bitcoin-and-expanse-4382f0a2f17) (about ETH/BTC 2-way peg without modifying bitcoin code).
* [BTCrelay audit](http://martin.swende.se/blog/BTCRelay-Auditing.html)

#### **RANDAO** <a href="#randao" id="randao"></a>

Random number \* <https://www.reddit.com/r/expanse/comments/49yld7/eli5_how_does_a_service_like_szabodice_grab_a/>

### **THE EVM** <a href="#the-evm" id="the-evm"></a>

The Expanse Virtual Machine (EVM) is the runtime environment for smart contracts in Expanse. It is not only sandboxed, but actually completely isolated, which means that code running inside the EVM has no access to network, filesystem, or other processes. Smart contracts even have limited access to other smart contracts.

Contracts live on the blockchain in an Expanse-specific binary format (EVM bytecode). However, contracts are typically written in an Expanse high level language, compiled into byte code using an EVM compiler, and finally uploaded on the blockchain using an Expanse client.


# Web3 base layer services

In addition to the Expanse blockchain, more components are being developed that decentralise other important aspects of web applications.

### **SWARM – DECENTRALISED DATA STORAGE AND DISTRIBUTION** <a href="#swarm-decentralised-data-storage-and-distribution" id="swarm-decentralised-data-storage-and-distribution"></a>

Swarm is a peer to peer data sharing network in which files are addressed by the hash of their content. Similar to Bittorrent, it is possible to fetch the data from many nodes at once and as long as a single node hosts a piece of data, it will remain accessible everywhere. This approach makes it possible to distribute data without having to host any kind of server – data accessibility is location independent.

Other nodes in the network can be incentivised to replicate and store the data themselves, obviating the need for hosting services when the original nodes are not connected to the network.

### **WHISPER – DECENTRALISED MESSAGING** <a href="#whisper-decentralised-messaging" id="whisper-decentralised-messaging"></a>

A protocol for private, secure communication directly between nodes.

Furthermore, standard contracts are being created to make the development and usage of distributed applications easier:

### **NAME REGISTRY** <a href="#name-registry" id="name-registry"></a>

Because dapps can be stored anywhere, including the Swarm network, the name registry maps names to their content or location. This is a decentralised alternative to the Domain Name System (DNS).

See <https://github.com/expanse-org/EIPs/issues/26>

### **CONTRACT REGISTRY** <a href="#contract-registry" id="contract-registry"></a>

To publish the source code of a specific contract, its address has to be mapped to it. The contract registry stores this mapping. Users can then look up this mapping and verify the contract byte code.

See \* global registrar code \* namereg API


# Expanse Explorer

https\://github.com/expanse-org/explorer-1

&#x20;This branch is 13 commits ahead, 4 commits behind ethereumclassic:master.

## ETC Explorer

**Live Version:** [**etherhub.io**](http://etherhub.io/)

Follow the project progress at: [ETC Block Explorer Development](https://github.com/ethereumclassic/explorer)

### Local installation

Clone the repo

`git clone https://github.com/ethereumclassic/explorer`

Download [Nodejs and npm](https://docs.npmjs.com/getting-started/installing-node) if you don't have them

Install dependencies:

`npm install`

Install mongodb:

MacOS: `brew install mongodb`

Ubuntu: `sudo apt-get install -y mongodb-org`

### Populate the DB

This will fetch and parse the entire blockchain.

Setup your configuration file: `cp config.example.json config.json`

Edit `config.json` as you wish

Basic settings:

```
{
    "nodeAddr":     "localhost",
    "wsPort":       8546,
    "startBlock":   0,
    "endBlock":     "latest",
    "quiet":        true,
    "syncAll":      true,
    "patch":        true,
    "patchBlocks":  100,
    "bulkSize":     100,
    "settings": {
        "symbol": "ETC",
        "name": "Ethereum Classic",
        "title": "Ethereum Classic Block Explorer",
        "author": "Elaine",
        "rss": "https://ethereumclassic.org",
        "reddit": "https://www.reddit.com/r/EthereumClassic",
        "twitter": "https://twitter.com/eth_classic",
        "linkedin": "https://www.linkedin.com/company/ethereum-classic",
        "github": "https://github.com/ethereumclassic",
        "logo": "/img/explorer-logo.png",
        "copyright": "2019 © Ethereum Classic.",
        "poweredbyCustom": false,
        "poweredbyEtcImage": "/img/powered-by-etcexplorer-w.png",
        "poweredbyEtc": true,
        "useRichList": true,
        "useFiat": true,
        "miners": {
            "0xdf7d7e053933b5cc24372f878c90e62dadad5d42": "EtherMine",
            "0xc91716199ccde49dc4fafaeb68925127ac80443f": "F2Pool",
            "0x9eab4b0fc468a7f5d46228bf5a76cb52370d068d": "NanoPool",
            "0x1C0FA194a9d3B44313DCD849F3C6be6Ad270a0A4": "MiningPoolHub",
            "0x4750e296949b747df1585aa67beee8be903dd560": "UUPool",
            "0xef224fa5fad302b51f38898f4df499d7af127af0": "91pool",
            "0x0073Cf1B9230cF3EE8Cab1971B8DbeF21eA7B595": "2miners",
            "0x4c2b4e716883a2c3f6b980b70b577e54b9441060": "ETCPool PL",
            "0xd144e30a0571aaf0d0c050070ac435deba461fab": "Clona Network",
            "0x568f58bf1667504fdf5aa02d776c156f940178a5": "Whalesburg",
            "0x3b2d2613ad66d66ee0cb518aeeccc98e9e3b19c0": "private(0x3b2d2613)",
            "0x919973eb38844313dc31c41e140700d6e333f8d5": "private(0x919973eb)",
            "0xb205f337bad80e28351c7540b741c81470c4927f": "private(0xb205f337)",
            "0x232cad0429e653ab610fbcf7e7ebee2f05f28410": "private(0x232cad04)",
            "0x999c2944807874d3677ee3c6065c8a8a92721ac5": "NinjaPool.jp",
            "0x39cd14977601184b7da518fd352261aad0cb9fd3": "91pool",
            "0xf35074bbd0a9aee46f4ea137971feec024ab704e": "Solo Mining Pools",
            "0xa97ed75172773ec705c2c78d999d3203199101bd": "epool",
            "0x58b3cabd0c5c777da2c1c4d4f7ecc8afe5674f20": "private(0x58b3cabd0)",
            "0x87cfd09c483fe65352456bb26c784a0e4c4ba389": "ArsMine",
            "0x5bc9ccbd3115cefb6f382d33e8ce2a0aba084da4": "private(0x5bc9ccbd3)",
            "0x4924414988feb1ee16e29298509f96317400eb57": "private(0x492441498)",
            "0xa9a926bed50dc038b20bb20de361e4c35aae51fc": "private(0xa9a926bed)",
            "0x0073cf1b9230cf3ee8cab1971b8dbef21ea7b595": "2miners",
            "0x004730417cd2b1d19f6be2679906ded4fa8a64e2": "2miners",
            "0x1c0fa194a9d3b44313dcd849f3c6be6ad270a0a4": "MiningPoolHub"
         }
    }
}
```

| Name          | Explanation                                                                                                                                                                                               |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `nodeAddr`    | Your node API RPC address.                                                                                                                                                                                |
| `wsPort`      | Your node API WS (Websocket) port. (RPC HTTP port is deprecated on Web3 1.0 see <https://web3js.readthedocs.io/en/1.0/web3.html#value>)                                                                   |
| `startBlock`  | This is the start block of the blockchain, should always be 0 if you want to sync the whole ETC blockchain.                                                                                               |
| `endBlock`    | This is usually the 'latest'/'newest' block in the blockchain, this value gets updated automatically, and will be used to patch missing blocks if the whole app goes down.                                |
| `quiet`       | Suppress some messages. (admittedly still not quiet)                                                                                                                                                      |
| `syncAll`     | If this is set to true at the start of the app, the sync will start syncing all blocks from lastSync, and if lastSync is 0 it will start from whatever the endBlock or latest block in the blockchain is. |
| `patch`       | If set to true and below value is set, sync will iterated through the # of blocks specified.                                                                                                              |
| `patchBlocks` | If `patch` is set to true, the amount of block specified will be check from the latest one.                                                                                                               |
| `useRichList` | If `useRichList` is set to true, explorer will update account balance for richlist page.                                                                                                                  |
| `useFiat`     | If `useFiat` is set to true, explorer will show price for account & tx page. ( Disable for testnets )                                                                                                     |

#### Mongodb Auth setting.

**Configure MongoDB**

In view of system security, most of mongoDB Admin has setup security options, So, You need to setup mongodb auth informations. Switch to the built-in admin database:

```
$ mongo
$ > use admin
```

1. Create an administrative user (if you have already admin or root of mongodb account, then skip it)

```
# make admin auth and role setup
$ > db.createUser( { user: "admin", pwd: "", roles: ["root"] } )
```

And, You can make Explorer's "explorerDB" database with db user accounts "explorer" and password "some\_pass\_code".

```
$ > use explorerDB
$ > db.createUser( { user: "explorer", pwd: "", roles: ["dbOwner"] } )
$ > quit()
```

Above dbuser explorer will full access explorerDB and clustor setting will be well used on monitoring the multiple sharding and replication of multiple mongodb instances. Enable database authorization in the MongoDB configuration file /etc/mongodb.conf by appending the following lines:

```
auth=true
```

Restart MongoDB and verify the administrative user created earlier can connect:

```
$ sudo service mongodb restart
$ mongo -u admin -p your_password --authenticationDatabase=admin
```

If everything is configured correctly the Mongo Shell will connect and

```
$ > show dbs
```

will show db informations. and You can add modified from ./db.js:148 lines, add auth information and mongodb connect options.

```
mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/explorerDB', {
  useMongoClient: true
  // poolSize: 5,
  // rs_name: 'myReplicaSetName',
  // user: 'explorer',
  // pass: 'yourdbpasscode'
});
```

And explore it.

#### Run

The below will start both the web-gui and sync.js (which populates MongoDB with blocks/transactions).

`npm start`

You can leave sync.js running without app.js and it will sync and grab blocks based on config.json parameters

`npm run sync`

Enabling stats requires running a separate process:

`npm run stats`

Enabling richlist requires running a separate process:

`npm run rich`

You can configure intervals (how often a new data point is pulled) and range (how many blocks to go back) with the following:

`RESCAN=100:7700000 node tools/stats.js` (New data point every 100 blocks. Go back 7,700,000 blocks).

### Docker installation

Set `nodeAddr` in `config.json` to `host.docker.internal`

Run `docker-compose up`


# Mist

https\://github.com/expanse-org/mist

&#x20;This branch is 41 commits ahead, 968 commits behind ethereum:master.

## Mist Browser

[![Join the chat at https://gitter.im/expanse-org/mist](https://camo.githubusercontent.com/5dbac0213da25c445bd11f168587c11a200ba153ef3014e8408e462e410169b3/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/expanse-org/mist?utm_source=badge\&utm_medium=badge\&utm_campaign=pr-badge\&utm_content=badge) [![Build Status develop branch](https://camo.githubusercontent.com/c92e1b4fd733143463d627958ec044609ea7955e37f48a395913d074df6441a5/68747470733a2f2f7472617669732d63692e6f72672f657870616e73652d6f72672f6d6973742e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/expanse-org/mist) [![Code Climate](https://camo.githubusercontent.com/f96c3f4da6c4aa6056ad9f38d51b2aa458be6790b54245a697d875f54ef17ab6/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f657870616e73652d6f72672f6d6973742f6261646765732f6770612e737667)](https://codeclimate.com/github/expanse-org/mist)

The Mist browser is the tool of choice to browse and use Ðapps.

For the Mist API see the [MISTAPI.md](https://github.com/expanse-org/mist/blob/master/MISTAPI.md).

### Installation

If you want install the app from a pre-built version on the [release page](https://github.com/expanse-org/mist/releases), you can simply run the executable after download.

For updating simply download the new version and copy it over the old one (keep a backup of the old one if you want to be sure).

**Config folder**

The data folder for Mist is stored in other places:

* Windows `%APPDATA%\Mist`
* macOS `~/Library/Application Support/Mist`
* Linux `~/.config/Mist`

### Development

For development, a Meteor server will to be started to assist with live reload and CSS injection. Once a Mist version is released the Meteor frontend part is bundled using `meteor-build-client` npm package to create pure static files.

#### Dependencies

To run mist in development you need:

* [Node.js](https://nodejs.org/) `v6.x` (use the prefered installation method for your OS)
* [Meteor](https://www.meteor.com/install) javascript app framework
* [Yarn](https://yarnpkg.com/) package manager
* [Electron](http://electron.atom.io/) `v1.3.13` cross platform desktop app framework
* [Gulp](http://gulpjs.com/) build and automation system

Install the later ones via:

```
$ curl https://install.meteor.com/ | sh
$ curl -o- -L https://yarnpkg.com/install.sh | bash
$ yarn global add electron@1.3.13
$ yarn global add gulp
```

#### Initialisation

Now you're ready to initialize Mist for development:

```
$ git clone https://github.com/expanse-org/mist.git
$ cd mist
$ yarn
```

To update Mist in the future, run:

```
$ cd mist
$ git pull
$ yarn
```

#### Run Mist

For development we start the interface with a Meteor server for auto reload etc. *Start the interface in a separate terminal window:*

```
$ cd mist/interface && meteor --no-release-check
```

In the original window you can then start Mist with:

```
$ cd mist
$ electron .
```

*NOTE: client-binaries (e.g.* [*geth*](https://github.com/expanse-org/go-expanse)*) specified in* [*clientBinaries.json*](https://github.com/expanse-org/mist/blob/master/clientBinaries.json) *will be checked during every startup and downloaded if out-of-date, binaries are stored in the* [*config folder*](broken://pages/-MRbfdVcPghfEiydUBMj#config-folder)

*NOTE: use `--help` to display available options, e.g. `--loglevel debug` (or `trace`) for verbose output*

#### Run the Wallet

Start the wallet app for development, *in a separate terminal window:*

```
$ cd mist/interface && meteor --no-release-check

// and in another terminal

$ cd my/path/meteor-dapp-wallet/app && meteor --port 3050
```

In the original window you can then start Mist using wallet mode:

```
$ cd mist
$ electron . --mode wallet
```

#### Connecting to node via HTTP instead of IPC

This is useful if you have a node running on another machine, though note that it's less secure than using the default IPC method.

```
$ electron . --rpc http://localhost:8545
```

#### Passing options to Gexp

You can pass command-line options directly to Gexp by prefixing them with `--node-` in the command-line invocation:

```
$ electron . --mode mist --node-rpcport 19343 --node-networkid 2
```

The `--rpc` Mist option is a special case. If you set this to an IPC socket file path then the `--ipcpath` option automatically gets set, i.e.:

```
$ electron . --rpc /my/gexp.ipc
```

...is the same as doing...

```
$ electron . --rpc /my/gexp.ipc --node-ipcpath /my/gexp.ipc
```

#### Using Mist with a privatenet

To run a private network you will need to set the IPC path, network id and data folder:

```
$ electron . --rpc ~/Library/Expanse/gexp.ipc --node-networkid 1234  --node-datadir ~/Library/Expanse/privatenet
```

*NOTE: since `ipcpath` is also a Mist option you do not need to also include a `--node-ipcpath` option.*

You can also run `gexp` separately yourself with the same options prior to start Mist normally.

#### Deployment

To create a binaries you need to install [`electron-builder` dependencies](https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build#macos):

```
// tools for the windows binaries
$ brew install wine --without-x11 mono makensis
// tools for the Linux binaries
$ brew install gnu-tar libicns graphicsmagick xz
// general dependencies
$ npm install -g meteor-build-client
```

To generate the binaries simply run:

```
$ cd mist
$ gulp

// Or to generate the wallet (using the https://github.com/expanse-org/meteor-dapp-wallet -> master)
$ gulp wallet
```

This will generate the binaries inside the `dist_mist/release` or `dist_wallet/release` folder.

**Options**

**platform**

Additional you can only build the windows, linux, mac or all binary by using the `platform` option:

```
$ gulp update-nodes --platform mac

// And
$ gulp mist --platform mac

// Or
$ gulp mist --platform mac,win
```

Options are:

* `mac` (Mac OSX)
* `win` (Windows)
* `linux` (Linux)
* `all` (default)

**walletSource**

With the `walletSource` you can specify the branch to use, default ist `master`:

```
$ gulp mist --walletSource develop
```

Options are:

* `master`
* `develop`
* `local` Will try to build the wallet from \[mist/]../meteor-dapp-wallet/app

**mist-checksums | wallet-checksums**

Spits out the SHA256 checksums of distributables.

It expects installer/zip files to be in the generated folders e.g. `dist_mist/release`

```
$ gulp mist-checksums

3f726fff186b85c600ea2459413d0bf5ada2dbc98877764efbefa545f96eb975  ./dist_mist/release/Mist-0.8.1-ia32.exe
ab4d26d5ebc66e9aba0fa610071266bacbb83faacbb7ed0dd2acb24386190bdb  ./dist_mist/release/Mist-0.8.1.exe
909b0fb4c7b09b731b2a442c457747e04ffdd9c03b6edc06079ae05a46200d13  ./dist_mist/release/Mist-0.8.1-ia32.deb
e114d6188963dfdae0489abf4e8923da58b39ff9cdbaad26e803af27c7ce55d1  ./dist_mist/release/Mist-0.8.1.deb
930787dd2f5ed6931068bff9244bccc01f397f552c48ded0f08e515e276dd080  ./dist_mist/release/Mist-0.8.1.dmg
```

#### Code signing for production

**As of** [**#972**](https://github.com/expanse-org/mist/pull/972) **we've updated the build process and thus need to redo code-signing.**

### Testing

First make sure to build Mist with: `gulp mist --platform [mac,linux]` or `gulp wallet --platform [mac,linux]`.

Then run `gulp test-mist` or `gulp test-wallet`, accordingly.


# Exp Miner

https\://github.com/expanse-org/expminer

&#x20;This branch is 92 commits behind ethereum-mining:master.

## ethminer

[![standard-readme compliant](https://camo.githubusercontent.com/4acde561661466fafff113c75a14b0c4bc4ffdd18430e4954f14edbd992714e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f726561646d652532307374796c652d7374616e646172642d627269676874677265656e2e737667)](https://github.com/RichardLitt/standard-readme) [![Gitter](https://camo.githubusercontent.com/9847ff4337174c20e5fe5d125928134dca305514e5c0b554013c3839992c9cf2/68747470733a2f2f696d672e736869656c64732e696f2f6769747465722f726f6f6d2f6e776a732f6e772e6a732e737667)](https://gitter.im/ethereum-mining/ethminer) [![Releases](https://camo.githubusercontent.com/fab4f391125422ddb2e698134a523ae81c07b5a09ccd63ec551acc0b6a6ad4b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f657468657265756d2d6d696e696e672f6574686d696e65722f746f74616c2e737667)](https://github.com/ethereum-mining/ethminer/releases)

> Ethereum miner with OpenCL, CUDA and stratum support

**Ethminer** is an Ethash GPU mining worker: with ethminer you can mine every coin which relies on an Ethash Proof of Work thus including Ethereum, Ethereum Classic, Metaverse, Musicoin, Ellaism, Pirl, Expanse and others. This is the actively maintained version of ethminer. It originates from [cpp-ethereum](https://github.com/ethereum/cpp-ethereum) project (where GPU mining has been discontinued) and builds on the improvements made in [Genoil's fork](https://github.com/Genoil/cpp-ethereum). See [FAQ](broken://pages/-MRbgFLA1yK9RnhZWJze#faq) for more details.

### Features

* OpenCL mining
* Nvidia CUDA mining
* realistic benchmarking against arbitrary epoch/DAG/blocknumber
* on-GPU DAG generation (no more DAG files on disk)
* stratum mining without proxy
* OpenCL devices picking
* farm failover (getwork + stratum)

### Table of Contents

* [Install](broken://pages/-MRbgFLA1yK9RnhZWJze#install)
* [Usage](broken://pages/-MRbgFLA1yK9RnhZWJze#usage)
  * [Examples connecting to pools](broken://pages/-MRbgFLA1yK9RnhZWJze#examples-connecting-to-pools)
* [Build](broken://pages/-MRbgFLA1yK9RnhZWJze#build)
  * [Continuous Integration and development builds](broken://pages/-MRbgFLA1yK9RnhZWJze#continuous-integration-and-development-builds)
  * [Building from source](broken://pages/-MRbgFLA1yK9RnhZWJze#building-from-source)
* [Maintainers & Authors](broken://pages/-MRbgFLA1yK9RnhZWJze#maintainers--authors)
* [Contribute](broken://pages/-MRbgFLA1yK9RnhZWJze#contribute)
* [F.A.Q.](broken://pages/-MRbgFLA1yK9RnhZWJze#faq)

### Install

[![Releases](https://camo.githubusercontent.com/fab4f391125422ddb2e698134a523ae81c07b5a09ccd63ec551acc0b6a6ad4b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f657468657265756d2d6d696e696e672f6574686d696e65722f746f74616c2e737667)](https://github.com/ethereum-mining/ethminer/releases)

Standalone **executables** for *Linux*, *macOS* and *Windows* are provided in the [Releases](https://github.com/ethereum-mining/ethminer/releases) section. Download an archive for your operating system and unpack the content to a place accessible from command line. The ethminer is ready to go.

| Builds | Release                                                                                                                                                                                                                                                                                                                     | Date                                                                                                                                                                                                                                                                                                                                       |
| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Last   | [![GitHub release](https://camo.githubusercontent.com/3fe681c48847840d05b350d61033d79af6851b5c1920f5454882a4752899087d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f657468657265756d2d6d696e696e672f6574686d696e65722f616c6c2e737667)](https://github.com/ethereum-mining/ethminer/releases) | [![GitHub Release Date](https://camo.githubusercontent.com/86b7c88c7c7523a17e9abc2674fb1b061db2da3d94da52461ce0852a456812b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652d7072652f657468657265756d2d6d696e696e672f6574686d696e65722e737667)](https://github.com/ethereum-mining/ethminer/releases) |
| Stable | [![GitHub release](https://camo.githubusercontent.com/e4c16234c1bd393ddd672407f5fed59c4683e4f5f68c0a396dd503830ba05108/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f657468657265756d2d6d696e696e672f6574686d696e65722e737667)](https://github.com/ethereum-mining/ethminer/releases/latest)  | [![GitHub Release Date](https://camo.githubusercontent.com/1bc86788050d89a792545c8ce7f77b676bebe216d2b82c066338268105b168f6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f657468657265756d2d6d696e696e672f6574686d696e65722e737667)](https://github.com/ethereum-mining/ethminer/releases/latest)  |

### Usage

The **ethminer** is a command line program. This means you launch it either from a Windows command prompt or Linux console, or create shortcuts to predefined command lines using a Linux Bash script or Windows batch/cmd file. For a full list of available command, please run:

#### Examples connecting to pools

Check our [samples](https://github.com/expanse-org/expminer/blob/master/docs/POOL_EXAMPLES_ETH.md) to see how to connect to different pools.

### Build

#### Continuous Integration and development builds

| CI                                                                   | OS           | Status                                                                                                                                                                                                                                                                                                                    | Development builds                                                                                         |
| -------------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| [Travis CI](https://travis-ci.org/ethereum-mining/ethminer)          | Linux, macOS | [![Travis CI](https://camo.githubusercontent.com/ba9d3a03352e9d287797a5db3e0179537d571952b11b5c53e6ec0c70984f7ace/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f657468657265756d2d6d696e696e672f6574686d696e65722f6d61737465722e737667)](https://travis-ci.org/ethereum-mining/ethminer)                    | ✗ No build artifacts, [Amazon S3 is needed](https://docs.travis-ci.com/user/uploading-artifacts/) for this |
| [AppVeyor](https://ci.appveyor.com/project/ethereum-mining/ethminer) | Windows      | [![AppVeyor](https://camo.githubusercontent.com/b0dfdaa1308c7f94837168e68dbc04c0c7a518ceeda47c17b3681c7e3995ea60/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f657468657265756d2d6d696e696e672f6574686d696e65722f6d61737465722e737667)](https://ci.appveyor.com/project/ethereum-mining/ethminer) | ✓ Build artifacts available for all PRs and branches                                                       |

The AppVeyor system automatically builds a Windows .exe for every commit. The latest version is always available [on the landing page](https://ci.appveyor.com/project/ethereum-mining/ethminer) or you can [browse the history](https://ci.appveyor.com/project/ethereum-mining/ethminer/history) to access previous builds.

To download the .exe on a build under `Job name` select the CUDA version you use, choose `Artifacts` then download the zip file.

#### Building from source

See [docs/BUILD.md](https://github.com/expanse-org/expminer/blob/master/docs/BUILD.md) for build/compilation details.

### Maintainers & Authors

[![Gitter](https://camo.githubusercontent.com/4bd3422ac11827277ae4569b722ecd61f1b3549c500567159b30d253275b4245/68747470733a2f2f696d672e736869656c64732e696f2f6769747465722f726f6f6d2f657468657265756d2d6d696e696e672f6574686d696e65722e737667)](https://gitter.im/ethereum-mining/ethminer)

The list of current and past maintainers, authors and contributors to the ethminer project. Ordered alphabetically. [Contributors statistics since 2015-08-20](https://github.com/ethereum-mining/ethminer/graphs/contributors?from=2015-08-20).

| Name                  | Contact                                                      |                                                 |
| --------------------- | ------------------------------------------------------------ | ----------------------------------------------- |
| Andrea Lanfranchi     | [@AndreaLanfranchi](https://github.com/AndreaLanfranchi)     | ETH: 0xa7e593bde6b5900262cf94e4d75fb040f7ff4727 |
| EoD                   | [@EoD](https://github.com/EoD)                               |                                                 |
| Genoil                | [@Genoil](https://github.com/Genoil)                         |                                                 |
| goobur                | [@goobur](https://github.com/goobur)                         |                                                 |
| Marius van der Wijden | [@MariusVanDerWijden](https://github.com/MariusVanDerWijden) | ETH: 0x57d22b967c9dc64e5577f37edf1514c2d8985099 |
| Paweł Bylica          | [@chfast](https://github.com/chfast)                         | ETH: 0x8FB24C5b5a75887b429d886DBb57fd053D4CF3a2 |
| Philipp Andreas       | [@smurfy](https://github.com/smurfy)                         |                                                 |
| Stefan Oberhumer      | [@StefanOberhumer](https://github.com/StefanOberhumer)       |                                                 |

### Contribute

[![Gitter](https://camo.githubusercontent.com/4bd3422ac11827277ae4569b722ecd61f1b3549c500567159b30d253275b4245/68747470733a2f2f696d672e736869656c64732e696f2f6769747465722f726f6f6d2f657468657265756d2d6d696e696e672f6574686d696e65722e737667)](https://gitter.im/ethereum-mining/ethminer)

To meet the community, ask general questions and chat about ethminer join [the ethminer channel on Gitter](https://gitter.im/ethereum-mining/ethminer).

All bug reports, pull requests and code reviews are very much welcome.

### License

Licensed under the [GNU General Public License, Version 3](broken://pages/-MRbgFLEa3vGmgEZ2_X0).

### F.A.Q

#### Why is my hashrate with Nvidia cards on Windows 10 so low?

The new WDDM 2.x driver on Windows 10 uses a different way of addressing the GPU. This is good for a lot of things, but not for ETH mining.

* For Kepler GPUs: I actually don't know. Please let me know what works best for good old Kepler.
* For Maxwell 1 GPUs: Unfortunately the issue is a bit more serious on the GTX750Ti, already causing suboptimal performance on Win7 and Linux. Apparently about 4MH/s can still be reached on Linux, which, depending on ETH price, could still be profitable, considering the relatively low power draw.
* For Maxwell 2 GPUs: There is a way of mining ETH at Win7/8/Linux speeds on Win10, by downgrading the GPU driver to a Win7 one (350.12 recommended) and using a build that was created using CUDA 6.5.
* For Pascal GPUs: You have to use the latest WDDM 2.1 compatible drivers in combination with Windows 10 Anniversary edition in order to get the full potential of your Pascal GPU.

#### Why is a GTX 1080 slower than a GTX 1070?

Because of the GDDR5X memory, which can't be fully utilized for ETH mining (yet).

#### Are AMD cards also affected by slowdowns with increasing DAG size?

Only GCN 1.0 GPUs (78x0, 79x0, 270, 280), but in a different way. You'll see that on each new epoch (30K blocks), the hashrate will go down a little bit.

#### Can I still mine ETH with my 2GB GPU?

Not really, your VRAM must be above the DAG size (Currently about 2.15 GB.) to get best performance. Without it severe hash loss will occur.

#### What are the optimal launch parameters?

The default parameters are fine in most scenario's (CUDA). For OpenCL it varies a bit more. Just play around with the numbers and use powers of 2. GPU's like powers of 2.

#### What does the `--cuda-parallel-hash` flag do?

[@davilizh](https://github.com/davilizh) made improvements to the CUDA kernel hashing process and added this flag to allow changing the number of tasks it runs in parallel. These improvements were optimised for GTX 1060 GPUs which saw a large increase in hashrate, GTX 1070 and GTX 1080/Ti GPUs saw some, but less, improvement. The default value is 4 (which does not need to be set with the flag) and in most cases this will provide the best performance.

#### What is ethminer's relationship with [Genoil's fork](https://github.com/Genoil/cpp-ethereum)?

[Genoil's fork](https://github.com/Genoil/cpp-ethereum) was the original source of this version, but as Genoil is no longer consistently maintaining that fork it became almost impossible for developers to get new code merged there. In the interests of progressing development without waiting for reviews this fork should be considered the active one and Genoil's as legacy code.

#### Can I CPU Mine?

No, use geth, the go program made for ethereum by ethereum.

#### CUDA GPU order changes sometimes. What can I do?

There is an environment var `CUDA_DEVICE_ORDER` which tells the Nvidia CUDA driver how to enumerates the graphic cards. The following values are valid:

* `FASTEST_FIRST` (Default) - causes CUDA to guess which device is fastest using a simple heuristic.
* `PCI_BUS_ID` - orders devices by PCI bus ID in ascending order.

To prevent some unwanted changes in the order of your CUDA devices you **might set the environment variable to `PCI_BUS_ID`**. This can be done with one of the 2 ways:

* Linux:
  * Adapt the `/etc/environment` file and add a line `CUDA_DEVICE_ORDER=PCI_BUS_ID`
  * Adapt your start script launching ethminer and add a line `export CUDA_DEVICE_ORDER=PCI_BUS_ID`
* Windows:
  * Adapt your environment using the control panel (just search `setting environment windows control panel` using your favorite search engine)
  * Adapt your start (.bat) file launching ethminer and add a line `set CUDA_DEVICE_ORDER=PCI_BUS_ID` or `setx CUDA_DEVICE_ORDER PCI_BUS_ID`. For more info about `set` see [here](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1), for more info about `setx` see [here](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/setx)

#### Insufficient CUDA driver

```
Error: Insufficient CUDA driver: 9010
```

You have to upgrade your Nvidia drivers. On Linux, install `nvidia-396` package or newer.


# Payroll dapp

https\://github.com/expanse-org/payroll-dapp

## PAYROLL dapp

PAY ROLL DAPP

### Price Oracle Address

`0xb385fa580fc98c0291d40f3960bea4f36b404976`

### Payroll Oracle Address

`0xed201029d05de2b63fed87b8d9254ddc9e4e5159`

## Payroll Contract ABI

```
[
	{
		"constant": true,
		"inputs": [],
		"name": "prices",
		"outputs": [
			{
				"name": "",
				"type": "address"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [
			{
				"name": "",
				"type": "address"
			}
		],
		"name": "balances",
		"outputs": [
			{
				"name": "",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [
			{
				"name": "_n",
				"type": "uint256"
			}
		],
		"name": "calcEXP",
		"outputs": [
			{
				"name": "",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [
			{
				"name": "_name",
				"type": "bytes16"
			}
		],
		"name": "employeeLookUp",
		"outputs": [
			{
				"name": "",
				"type": "address"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [],
		"name": "totalEXPPay",
		"outputs": [
			{
				"name": "",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [
			{
				"name": "",
				"type": "address"
			}
		],
		"name": "emps",
		"outputs": [
			{
				"name": "isActive",
				"type": "bool"
			},
			{
				"name": "isEXP",
				"type": "bool"
			},
			{
				"name": "payRate",
				"type": "uint256"
			},
			{
				"name": "name",
				"type": "bytes16"
			},
			{
				"name": "nextPay",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [],
		"name": "expHardCap",
		"outputs": [
			{
				"name": "",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			}
		],
		"name": "getEmployee",
		"outputs": [
			{
				"name": "isActive",
				"type": "bool"
			},
			{
				"name": "isEXP",
				"type": "bool"
			},
			{
				"name": "payRate",
				"type": "uint256"
			},
			{
				"name": "expBalance",
				"type": "uint256"
			},
			{
				"name": "expPayRate",
				"type": "uint256"
			},
			{
				"name": "name",
				"type": "bytes16"
			},
			{
				"name": "nextPay",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [],
		"name": "getPrice",
		"outputs": [
			{
				"name": "",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [],
		"name": "root",
		"outputs": [
			{
				"name": "",
				"type": "address"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [],
		"name": "totalUSDPay",
		"outputs": [
			{
				"name": "",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [
			{
				"name": "",
				"type": "bytes32"
			}
		],
		"name": "names",
		"outputs": [
			{
				"name": "",
				"type": "address"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [
			{
				"name": "",
				"type": "address"
			}
		],
		"name": "admins",
		"outputs": [
			{
				"name": "",
				"type": "bool"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": true,
		"inputs": [
			{
				"name": "",
				"type": "uint256"
			}
		],
		"name": "employees",
		"outputs": [
			{
				"name": "",
				"type": "address"
			}
		],
		"payable": false,
		"stateMutability": "view",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			}
		],
		"name": "payEmployee",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"anonymous": false,
		"inputs": [
			{
				"indexed": true,
				"name": "Employee",
				"type": "address"
			},
			{
				"indexed": false,
				"name": "Rate",
				"type": "uint256"
			}
		],
		"name": "PayedEmployee",
		"type": "event"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			},
			{
				"name": "_isActive",
				"type": "bool"
			}
		],
		"name": "setIsActive",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [],
		"name": "withdraw",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			},
			{
				"name": "_isEXP",
				"type": "bool"
			}
		],
		"name": "setIsEXP",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			}
		],
		"name": "removeEmployee",
		"outputs": [
			{
				"name": "",
				"type": "bool"
			}
		],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			},
			{
				"name": "_nextPay",
				"type": "uint256"
			}
		],
		"name": "setNextPay",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_newOwner",
				"type": "address"
			}
		],
		"name": "transferRoot",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [],
		"name": "calcTotalPay",
		"outputs": [
			{
				"name": "",
				"type": "uint256"
			},
			{
				"name": "",
				"type": "uint256"
			}
		],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [],
		"name": "kill",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"payable": true,
		"stateMutability": "payable",
		"type": "fallback"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			},
			{
				"name": "_isActive",
				"type": "bool"
			},
			{
				"name": "_isEXP",
				"type": "bool"
			},
			{
				"name": "_payRate",
				"type": "uint256"
			}
		],
		"name": "setEmployee",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"inputs": [],
		"payable": true,
		"stateMutability": "payable",
		"type": "constructor"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_expHardCap",
				"type": "uint256"
			}
		],
		"name": "setExpHardCap",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [],
		"name": "payEmployees",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			},
			{
				"name": "_payRate",
				"type": "uint256"
			},
			{
				"name": "_isEXP",
				"type": "bool"
			},
			{
				"name": "_name",
				"type": "bytes16"
			}
		],
		"name": "addEmployee",
		"outputs": [
			{
				"name": "",
				"type": "bool"
			}
		],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_oldAcct",
				"type": "address"
			},
			{
				"name": "_newAccount",
				"type": "address"
			}
		],
		"name": "transferEmployeeAcct",
		"outputs": [
			{
				"name": "",
				"type": "bool"
			}
		],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_prices",
				"type": "address"
			}
		],
		"name": "setPrices",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_e",
				"type": "address"
			},
			{
				"name": "_payRate",
				"type": "uint256"
			}
		],
		"name": "setPayRate",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "index",
				"type": "uint256"
			}
		],
		"name": "removeIndex",
		"outputs": [
			{
				"name": "",
				"type": "address[]"
			}
		],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_sendTo",
				"type": "address"
			}
		],
		"name": "empty",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [],
		"name": "forceWithdrawAll",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"constant": false,
		"inputs": [
			{
				"name": "_acct",
				"type": "address"
			},
			{
				"name": "_set",
				"type": "bool"
			}
		],
		"name": "setAdmin",
		"outputs": [],
		"payable": false,
		"stateMutability": "nonpayable",
		"type": "function"
	}
]

```

## How To Setup Payroll Contracts

* &#x20;Launch payroll contract with price oracle
* &#x20;setEXPHardCap
* &#x20;Add employees
* &#x20;calcTotal
* &#x20;Send EXP to contract equivalent to the return of the “totalEXPPay” call

## How To Pay Employees

* &#x20;Click calcTotal
* &#x20;Update expanse price using price oracle (expPrice \* 100)
* &#x20;Divide totalUSDPay by getPrice
* &#x20;Send exp to contract
* &#x20;Click “pay employees”
* &#x20;Employees can then withdraw their funds at will

## How To Setup Payroll With MEW

* &#x20;Go to myetherwallet.com
* &#x20;Go to contracts tab
* &#x20;Copy and paste payroll oracle contract address
* &#x20;Copy and paste payroll abi json
* &#x20;Click access
* &#x20;Load your address up
* &#x20;Select “withdraw” from drop down menu

#### Notes

Make sure to use the address you supplied me to withdraw your funds.

## How to Setup Payroll with Mist / Luna

* &#x20;Open mist
* &#x20;Go to contracts tab
* &#x20;Click “watch contract”
* &#x20;Copy and paste payroll contract address into address field
* &#x20;Copy and paste payroll contract abi into abi field
* &#x20;type “Payroll” into name field
* &#x20;Click ok
* &#x20;Click “Payroll” on contracts tab
* &#x20;On the right side select “withdraw” from “pick a function” dropdown menu
* &#x20;Select your address from “execute from” drop down menu

#### Notes

Make sure to use the address you supplied me to withdraw your funds.


# Go-expanse

https\://github.com/expanse-org/go-expanse

&#x20;This branch is 532 commits ahead, 774 commits behind ethereum:master.

## Expanse Go

Official golang implementation of the Expanse protocol.

[![API Reference](https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667)](https://godoc.org/github.com/expanse-org/go-expanse) [![Go Report Card](https://camo.githubusercontent.com/793629b55e3a56b01ad8a6786b4b695b5b23739ce3903ec14461059be85def48/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f657870616e73652d6f72672f676f2d657870616e7365)](https://goreportcard.com/report/github.com/expanse-org/go-expanse) [![Travis](https://camo.githubusercontent.com/f468fb83ad4ac541896171d8f412bcebd835fd1aa06bacefbff175fef8aa1bb4/68747470733a2f2f7472617669732d63692e6f72672f657870616e73652d6f72672f676f2d657870616e73652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/expanse-org/go-expanse) [![Discord](https://camo.githubusercontent.com/bfe214c59b8b72f010057b0aea6becb32e4d13b965d86753ca5b2bb0f1dba48b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646973636f72642d6a6f696e253230636861742d626c75652e737667)](https://discord.me/expanse)

Automated builds are available for stable releases and the unstable master branch. Binary archives are published at <https://gexp.expanse.tech/downloads/>.

## Building the source

For prerequisites and detailed build instructions please read the [Installation Instructions](https://github.com/expanse-org/go-expanse/wiki/Building-Expanse) on the wiki.

Building gexp requires both a Go (version 1.9 or later) and a C compiler. You can install them using your favourite package manager. Once the dependencies are installed, run

```
make gexp
```

or, to build the full suite of utilities:

## Executables

The go-expanse project comes with several wrappers/executables found in the `cmd` directory.

| Command       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`gexp`**    | Our main Expanse CLI client. It is the entry point into the Expanse network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Expanse network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `gexp --help` and the [CLI Wiki page](https://github.com/expanse-org/go-expanse/wiki/Command-Line-Options) for command line options.           |
| `abigen`      | Source code generator to convert Expanse contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Expanse contract ABIs](https://github.com/expanse-org/wiki/wiki/Expanse-Contract-ABI) with expanded functionality if the contract bytecode is also available. However it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://github.com/expanse-org/go-expanse/wiki/Native-DApps:-Go-bindings-to-Expanse-contracts) wiki page for details. |
| `bootnode`    | Stripped down version of our Expanse client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks.                                                                                                                                                                                                                                                                  |
| `evm`         | Developer utility version of the EVM (Expanse Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug`).                                                                                                                                                                                                                                                                      |
| `gexprpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/ethereum/rpc-tests) test suite which validates baseline conformity to the [Expanse JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/ethereum/rpc-tests/blob/master/README.md) for details.                                                                                                                                                                                                      |
| `rlpdump`     | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)) dumps (data encoding used by the Expanse protocol both network as well as consensus wise) to user friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`).                                                                                                                                                                                                                                  |
| `swarm`       | Swarm daemon and tools. This is the entrypoint for the Swarm network. `swarm --help` for command line options and subcommands. See [Swarm README](https://github.com/expanse-org/go-expanse/tree/master/swarm) for more information.                                                                                                                                                                                                                                                                                                                 |
| `puppeth`     | a CLI wizard that aids in creating a new Expanse network.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

## Running gexp

Going through all the possible command line flags is out of scope here (please consult our [CLI Wiki page](https://github.com/expanse-org/go-expanse/wiki/Command-Line-Options)), but we've enumerated a few common parameter combos to get you up to speed quickly on how you can run your own Gexp instance.

### Full node on the main Expanse network

By far the most common scenario is people wanting to simply interact with the Expanse network: create accounts; transfer funds; deploy and interact with contracts. For this particular use-case the user doesn't care about years-old historical data, so we can fast-sync quickly to the current state of the network. To do so:

```
$ gexp --fast --cache=512 console
```

This command will:

* Start gexp in fast sync mode (default, can be changed with the `--syncmode` flag), causing it to download more data in exchange for avoiding processing the entire history of the Expanse network, which is very CPU intensive.
* Start up gexp's built-in interactive [JavaScript console](https://github.com/expanse-org/go-expanse/wiki/JavaScript-Console), (via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API) as well as Gexp's own [management APIs](https://github.com/expanse-org/go-expanse/wiki/Management-APIs). This tool is optional and if you leave it out you can always attach to an already running Gexp instance with `gexp attach`.

### Full node on the Expanse test network

Transitioning towards developers, if you'd like to play around with creating Expanse contracts, you almost certainly would like to do that without any real money involved until you get the hang of the entire system. In other words, instead of attaching to the main network, you want to join the **test** network with your node, which is fully equivalent to the main network, but with play-Ether only.

```
$ gexp --testnet --fast --cache=512 console
```

The `console` subcommand has the exact same meaning as above and they are equally useful on the testnet too. Please see above for their explanations if you've skipped here.

Specifying the `--testnet` flag, however, will reconfigure your `geth` instance a bit:

Specifying the `--testnet` flag however will reconfigure your Gexp instance a bit:

* Instead of using the default data directory (`~/.expanse` on Linux for example), Gexp will nest itself one level deeper into a `testnet` subfolder (`~/.expanse/testnet` on Linux). Note, on OSX and Linux this also means that attaching to a running testnet node requires the use of a custom endpoint since `gexp attach` will try to attach to a production node endpoint by default. E.g. `gexp attach/testnet/gexp.ipc`. Windows users are not affected by this.
* Instead of connecting the main Expanse network, the client will connect to the test network, which uses different P2P bootnodes, different network IDs and genesis states.

*Note: Although there are some internal protective measures to prevent transactions from crossing over between the main network and test network, you should make sure to always use separate accounts for play-money and real-money. Unless you manually move accounts, Gexp will by default correctly separate the two networks and will not make any accounts available between them.*

### Full node on the Rinkeby test network

The above test network is a cross client one based on the ethash proof-of-work consensus algorithm. As such, it has certain extra overhead and is more susceptible to reorganization attacks due to the network's low difficulty / security. Go Expanse also supports connecting to a proof-of-authority based test network called [*Rinkeby*](https://www.rinkeby.io/) (operated by members of the community). This network is lighter, more secure, but is only supported by go-ethereum.

```
$ gexp --rinkeby console
```

### Configuration

As an alternative to passing the numerous flags to the `gexp` binary, you can also pass a configuration file via:

```
$ gexp --config /path/to/your_config.toml
```

To get an idea how the file should look like you can use the `dumpconfig` subcommand to export your existing configuration:

```
$ gexp --your-favourite-flags dumpconfig
```

*Note: This works only with gexp v1.6.0 and above.*

#### Docker quick start

One of the quickest ways to get Expanse up and running on your machine is by using Docker:

```
docker run -d --name expanse-node -v /Users/alice/expanse:/root \
           -p 9656:9656 -p 42786:42786 \
           expanse/client-go --fast --cache=512
```

This will start gexp in fast sync mode with a DB memory allowance of 512MB just as the above command does. It will also create a persistent volume in your home directory for saving your blockchain as well as map the default ports. There is also an `alpine` tag available for a slim version of the image.

### Pragmatically interfacing Gexp nodes

As a developer, sooner rather than later you'll want to start interacting with Gexp and the Expanse network via your own programs and not manually through the console. To aid this, Gexp has built in support for a JSON-RPC based APIs ([standard APIs](https://github.com/expanse-org/wiki/wiki/JSON-RPC) and [Gexp specific APIs](https://github.com/expanse-org/go-expanse/wiki/Management-APIs)). These can be exposed via HTTP, WebSockets and IPC (unix sockets on unix based platroms, and named pipes on Windows).

The IPC interface is enabled by default and exposes all the APIs supported by Gexp, whereas the HTTP and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons. These can be turned on/off and configured as you'd expect.

HTTP based JSON-RPC API options:

* `--rpc` Enable the HTTP-RPC server
* `--rpcaddr` HTTP-RPC server listening interface (default: "localhost")
* `--rpcport` HTTP-RPC server listening port (default: 9656)
* `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3")
* `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced)
* `--ws` Enable the WS-RPC server
* `--wsaddr` WS-RPC server listening interface (default: `localhost`)
* `--wsport` WS-RPC server listening port (default: `8546`)
* `--wsapi` API's offered over the WS-RPC interface (default: `eth,net,web3`)
* `--wsorigins` Origins from which to accept websockets requests
* `--ipcdisable` Disable the IPC-RPC server
* `--ipcapi` API's offered over the IPC-RPC interface (default: `admin,debug,eth,miner,net,personal,shh,txpool,web3`)
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)

You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect via HTTP, WS or IPC to a Gexp node configured with the above flags and you'll need to speak [JSON-RPC](https://www.jsonrpc.org/specification) on all transports. You can reuse the same connection for multiple requests!

**Note: Please understand the security implications of opening up an HTTP/WS based transport before doing so! Hackers on the internet are actively trying to subvert Expanse nodes with exposed APIs! Further, all browser tabs can access locally running webservers, so malicious webpages could try to subvert locally available APIs!**

### Operating a private network

Maintaining your own private network is more involved as a lot of configurations taken for granted in the official networks need to be manually set up.

#### Defining the private genesis state

First, you'll need to create the genesis state of your networks, which all nodes need to be aware of and agree upon. This consists of a small JSON file (e.g. call it `genesis.json`):

```
{
  "config": {
    "chainId":  positive integer>,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0
  },
  "alloc": {},
  "coinbase": "0x0000000000000000000000000000000000000000",
  "difficulty": "0x20000",
  "extraData": "",
  "gasLimit": "0x2fefd8",
  "nonce": "0x0000000000000042",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x00"
}
```

The above fields should be fine for most purposes, although we'd recommend changing the `nonce` to some random value so you prevent unknown remote nodes from being able to connect to you. If you'd like to pre-fund some accounts for easier testing, create the accounts and populate the `alloc` field with their addresses.

```
"alloc": {
  "0x0000000000000000000000000000000000000001": {
    "balance": "111111111"
  },
  "0x0000000000000000000000000000000000000002": {
    "balance": "222222222"
  }
}
```

With the genesis state defined in the above JSON file, you'll need to initialize **every** Gexp node with it prior to starting it up to ensure all blockchain parameters are correctly set:

```
$ gexp init path/to/genesis.json
```

#### Creating the rendezvous point

With all nodes that you want to run initialized to the desired genesis state, you'll need to start a bootstrap node that others can use to find each other in your network and/or over the internet. The clean way is to configure and run a dedicated bootnode:

```
$ bootnode --genkey=boot.key
$ bootnode --nodekey=boot.key
```

With the bootnode online, it will display an [`enode` URL](https://github.com/expanse-org/wiki/wiki/enode-url-format) that other nodes can use to connect to it and exchange peer information. Make sure to replace the displayed IP address information (most probably `[::]`) with your externally accessible IP to get the actual `enode` URL.

*Note: You could also use a full fledged Gexp node as a bootnode, but it's the less recommended way.*

#### Starting up your member nodes

With the bootnode operational and externally reachable (you can try `telnet` to ensure it's indeed reachable), start every subsequent Gexp node pointed to the bootnode for peer discovery via the `--bootnodes` flag. It will probably also be desirable to keep the data directory of your private network separated, so do also specify a custom `--datadir` flag.

```
$ gexp --datadir=path/to/custom/data/folder --bootnodes=
```

*Note: Since your network will be completely cut off from the main and test networks, you'll also need to configure a miner to process transactions and create new blocks for you.*

#### Running a private miner

Mining on the public Expanse network is a complex task as it's only feasible using GPUs, requiring an OpenCL or CUDA enabled `ethminer` instance. For information on such a setup, please consult the [EtherMining subreddit](https://www.reddit.com/r/EtherMining/) and the [Genoil miner](https://github.com/Genoil/cpp-expanse) repository.

In a private network setting however, a single CPU miner instance is more than enough for practical purposes as it can produce a stable stream of blocks at the correct intervals without needing heavy resources (consider running on a single thread, no need for multiple ones either). To start a Gexp instance for mining, run it with all your usual flags, extended by:

```
$ gexp  --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000
```

Which will start mining blocks and transactions on a single CPU thread, crediting all proceedings to the account specified by `--etherbase`. You can further tune the mining by changing the default gas limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`).

## Contribution

Thank you for considering to help out with the source code! We welcome contributions from anyone on the internet, and are grateful for even the smallest of fixes!

If you'd like to contribute to go-expanse, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base. If you wish to submit more complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/expanse-org/go-expanse) to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple.

Please make sure your contributions adhere to our coding guidelines:

* Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
* Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
* Pull requests need to be based on and opened against the `master` branch.
* Commit messages should be prefixed with the package(s) they modify.
  * E.g. "eth, rpc: make trace configs optional"

Please see the [Developers' Guide](https://github.com/expanse-org/go-expanse/wiki/Developers'-Guide) for more details on configuring your environment, managing project dependencies and testing procedures.

## License

The go-expanse library (i.e. all code outside of the `cmd` directory) is licensed under the [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), also included in our repository in the `COPYING.LESSER` file.

The go-expanse binaries (i.e. all code inside of the `cmd` directory) is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also included in our repository in the `COPYING` file.


# Open expanse pool

https\://github.com/expanse-org/open-expanse-pool

&#x20;This branch is 14 commits ahead of sammy007:master.

## Open Source Expanse Mining Pool

[![Miner's stats page](https://user-images.githubusercontent.com/7374093/31591180-43c72364-b236-11e7-8d47-726cd66b876a.png)](https://user-images.githubusercontent.com/7374093/31591180-43c72364-b236-11e7-8d47-726cd66b876a.png)

[![Join the chat at https://gitter.im/expanse-org/open-expanse-pool](https://camo.githubusercontent.com/5dbac0213da25c445bd11f168587c11a200ba153ef3014e8408e462e410169b3/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/expanse-org/open-expanse-pool?utm_source=badge\&utm_medium=badge\&utm_campaign=pr-badge\&utm_content=badge) [![Build Status](https://camo.githubusercontent.com/ce8f151b09d61f4e6c721ecffb9c7110a678cec3dd79deecba4ae3c9adf50e39/68747470733a2f2f7472617669732d63692e6f72672f657870616e73652d6f72672f6f70656e2d657870616e73652d706f6f6c2e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/expanse-org/open-expanse-pool) [![Go Report Card](https://camo.githubusercontent.com/3cd09c514d48965eb72ce22aea99ddb8706661c62b588cf3b936924c1a12a5e6/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f657870616e73652d6f72672f6f70656e2d657870616e73652d706f6f6c)](https://goreportcard.com/report/github.com/expanse-org/open-expanse-pool)

### Features

**This pool is being further developed to provide an easy to use pool for Expanse miners. This software is functional however an optimised release of the pool is expected soon. Testing and bug submissions are welcome!**

* Support for HTTP and Stratum mining
* Detailed block stats with luck percentage and full reward
* Failover geth instances: geth high availability built in
* Modern beautiful Ember.js frontend
* Separate stats for workers: can highlight timed-out workers so miners can perform maintenance of rigs
* JSON-API for stats

#### Proxies

* [Ether-Proxy](https://github.com/expanse-org/ether-proxy) HTTP proxy with web interface
* [Stratum Proxy](https://github.com/Atrides/eth-proxy) for Expanse

### Building on Linux

Dependencies:

* go >= 1.9
* geth or parity
* redis-server >= 2.8.0
* nodejs >= 4 LTS
* nginx

**I highly recommend to use Ubuntu 16.04 LTS.**

First install [go-ethereum](https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu).

Clone & compile:

```
git config --global http.https://gopkg.in.followRedirects true
git clone https://github.com/expanse-org/open-expanse-pool.git
cd open-expanse-pool
make
```

Install redis-server.

### Running Pool

```
./build/bin/open-expanse-pool config.json
```

You can use Ubuntu upstart - check for sample config in `upstart.conf`.

### Building Frontend

Install nodejs. I suggest using LTS version >= 4.x from <https://github.com/nodesource/distributions> or from your Linux distribution or simply install nodejs on Ubuntu Xenial 16.04.

The frontend is a single-page Ember.js application that polls the pool API to render miner stats.

```
cd www
```

Change `ApiUrl: '//example.net/'` in `www/config/environment.js` to match your domain name. Also don't forget to adjust other options.

```
npm install -g ember-cli@2.9.1
npm install -g bower
npm install
bower install
./build.sh
```

Configure nginx to serve API on `/api` subdirectory. Configure nginx to serve `www/dist` as static website.

#### Serving API using nginx

Create an upstream for API:

```
upstream api {
    server 127.0.0.1:8080;
}
```

and add this setting after `location /`:

```
location /api {
    proxy_pass http://api;
}
```

#### Customization

You can customize the layout using built-in web server with live reload:

```
ember server --port 8082 --environment development
```

**Don't use built-in web server in production**.

Check out `www/app/templates` directory and edit these templates in order to customise the frontend.

### Configuration

Configuration is actually simple, just read it twice and think twice before changing defaults.

**Don't copy config directly from this manual. Use the example config from the package, otherwise you will get errors on start because of JSON comments.**

```
{
  // Set to the number of CPU cores of your server
  "threads": 2,
  // Prefix for keys in redis store
  "coin": "eth",
  // Give unique name to each instance
  "name": "main",

  "proxy": {
    "enabled": true,

    // Bind HTTP mining endpoint to this IP:PORT
    "listen": "0.0.0.0:8888",

    // Allow only this header and body size of HTTP request from miners
    "limitHeadersSize": 1024,
    "limitBodySize": 256,

    /* Set to true if you are behind CloudFlare (not recommended) or behind http-reverse
      proxy to enable IP detection from X-Forwarded-For header.
      Advanced users only. It's tricky to make it right and secure.
    */
    "behindReverseProxy": false,

    // Stratum mining endpoint
    "stratum": {
      "enabled": true,
      // Bind stratum mining socket to this IP:PORT
      "listen": "0.0.0.0:8008",
      "timeout": "120s",
      "maxConn": 8192
    },

    // Try to get new job from geth in this interval
    "blockRefreshInterval": "120ms",
    "stateUpdateInterval": "3s",
    // Require this share difficulty from miners
    "difficulty": 2000000000,

    /* Reply error to miner instead of job if redis is unavailable.
      Should save electricity to miners if pool is sick and they didn't set up failovers.
    */
    "healthCheck": true,
    // Mark pool sick after this number of redis failures.
    "maxFails": 100,
    // TTL for workers stats, usually should be equal to large hashrate window from API section
    "hashrateExpiration": "3h",

    "policy": {
      "workers": 8,
      "resetInterval": "60m",
      "refreshInterval": "1m",

      "banning": {
        "enabled": false,
        /* Name of ipset for banning.
        Check http://ipset.netfilter.org/ documentation.
        */
        "ipset": "blacklist",
        // Remove ban after this amount of time
        "timeout": 1800,
        // Percent of invalid shares from all shares to ban miner
        "invalidPercent": 30,
        // Check after after miner submitted this number of shares
        "checkThreshold": 30,
        // Bad miner after this number of malformed requests
        "malformedLimit": 5
      },
      // Connection rate limit
      "limits": {
        "enabled": false,
        // Number of initial connections
        "limit": 30,
        "grace": "5m",
        // Increase allowed number of connections on each valid share
        "limitJump": 10
      }
    }
  },

  // Provides JSON data for frontend which is static website
  "api": {
    "enabled": true,
    "listen": "0.0.0.0:8080",
    // Collect miners stats (hashrate, ...) in this interval
    "statsCollectInterval": "5s",
    // Purge stale stats interval
    "purgeInterval": "10m",
    // Fast hashrate estimation window for each miner from it's shares
    "hashrateWindow": "30m",
    // Long and precise hashrate from shares, 3h is cool, keep it
    "hashrateLargeWindow": "3h",
    // Collect stats for shares/diff ratio for this number of blocks
    "luckWindow": [64, 128, 256],
    // Max number of payments to display in frontend
    "payments": 50,
    // Max numbers of blocks to display in frontend
    "blocks": 50,

    /* If you are running API node on a different server where this module
      is reading data from redis writeable slave, you must run an api instance with this option enabled in order to purge hashrate stats from main redis node.
      Only redis writeable slave will work properly if you are distributing using redis slaves.
      Very advanced. Usually all modules should share same redis instance.
    */
    "purgeOnly": false
  },

  // Check health of each geth node in this interval
  "upstreamCheckInterval": "5s",

  /* List of geth nodes to poll for new jobs. Pool will try to get work from
    first alive one and check in background for failed to back up.
    Current block template of the pool is always cached in RAM indeed.
  */
  "upstream": [
    {
      "name": "main",
      "url": "http://127.0.0.1:8545",
      "timeout": "10s"
    },
    {
      "name": "backup",
      "url": "http://127.0.0.2:8545",
      "timeout": "10s"
    }
  ],

  // This is standard redis connection options
  "redis": {
    // Where your redis instance is listening for commands
    "endpoint": "127.0.0.1:6379",
    "poolSize": 10,
    "database": 0,
    "password": ""
  },

  // This module periodically remits ether to miners
  "unlocker": {
    "enabled": false,
    // Pool fee percentage
    "poolFee": 1.0,
    // Pool fees beneficiary address (leave it blank to disable fee withdrawals)
    "poolFeeAddress": "",
    // Donate 10% from pool fees to developers
    "donate": true,
    // Unlock only if this number of blocks mined back
    "depth": 120,
    // Simply don't touch this option
    "immatureDepth": 20,
    // Keep mined transaction fees as pool fees
    "keepTxFees": false,
    // Run unlocker in this interval
    "interval": "10m",
    // Geth instance node rpc endpoint for unlocking blocks
    "daemon": "http://127.0.0.1:8545",
    // Rise error if can't reach geth in this amount of time
    "timeout": "10s"
  },

  // Pay out miners using this module
  "payouts": {
    "enabled": false,
    // Require minimum number of peers on node
    "requirePeers": 25,
    // Run payouts in this interval
    "interval": "12h",
    // Geth instance node rpc endpoint for payouts processing
    "daemon": "http://127.0.0.1:8545",
    // Rise error if can't reach geth in this amount of time
    "timeout": "10s",
    // Address with pool balance
    "address": "0x0",
    // Let geth to determine gas and gasPrice
    "autoGas": true,
    // Gas amount and price for payout tx (advanced users only)
    "gas": "21000",
    "gasPrice": "50000000000",
    // Send payment only if miner's balance is >= 0.5 Ether
    "threshold": 500000000,
    // Perform BGSAVE on Redis after successful payouts session
    "bgsave": false
  }
}
```

If you are distributing your pool deployment to several servers or processes, create several configs and disable unneeded modules on each server. (Advanced users)

I recommend this deployment strategy:

* Mining instance - 1x (it depends, you can run one node for EU, one for US, one for Asia)
* Unlocker and payouts instance - 1x each (strict!)
* API instance - 1x

### Notes

* Unlocking and payouts are sequential, 1st tx go, 2nd waiting for 1st to confirm and so on. You can disable that in code. Carefully read `docs/PAYOUTS.md`.
* Also, keep in mind that **unlocking and payouts will halt in case of backend or node RPC errors**. In that case check everything and restart.
* You must restart module if you see errors with the word *suspended*.
* Don't run payouts and unlocker modules as part of mining node. Create separate configs for both, launch independently and make sure you have a single instance of each module running.
* If `poolFeeAddress` is not specified all pool profit will remain on coinbase address. If it specified, make sure to periodically send some dust back required for payments.

### Alternative Expanse Implementations

This pool is tested to work with [Ethcore's Parity](https://github.com/ethcore/parity). Mining and block unlocking works, but I am not sure about payouts and suggest to run *official* geth node for payments.

### Credits

Made by expanse-org. Licensed under GPLv3.

#### Contributors

[Alex Leverington](https://github.com/subtly)

### Donations

ETH/ETC: 0xb85150eb365e7df0941f0cf08235f987ba91506a

[![](https://camo.githubusercontent.com/efab76316c2559b09203c8bd66da9fc7029d76e1869f04c9dcfa0eb183ee9706/68747470733a2f2f63646e2e706272642e636f2f696d616765732f475035744931442e706e67)](https://camo.githubusercontent.com/efab76316c2559b09203c8bd66da9fc7029d76e1869f04c9dcfa0eb183ee9706/68747470733a2f2f63646e2e706272642e636f2f696d616765732f475035744931442e706e67)

Highly appreciated.


