-
Notifications
You must be signed in to change notification settings - Fork 604
Running the Testnet
This guide assumes that you already installed the pyethapp, if not see the Getting Started Page.
Using a testnet, allows users to access a network w/o having to have real Ethers. It is therefore also practical to use for contract-testing/developing purposes. Lastly the main advantage the testnet has over it's own private chain, is that one does not have to mine to get transactions and contracts on the chain. Usually there are already a few nodes in the network doing this for you w/o having hefty mining power. So you still can start mining and will get some Ether every now and then even on a mortal machine.
To access the testnet, called Morden, use the option --profile morden
. Additionally you need to specify a data directory in which you want to store the state of the Morden testnet using the option --datadir '../pyethapp/state'
. Where 'state' is the newly created state folder for the Morden testnet.
An example call would look like this:
pyethapp --profile morden --data-dir '/home/user/Ethereum/pyethapp/state' run
After you did that you will automatically sync with the testnet. This step takes some time, so go ahead and grab some coffee.
-
For creating, unlocking Accounts, as well as how to get some free Ether (on the testnet) see here.
-
For how to send transactions and creating contracts see here
Let's implement an interface for the namereg-contract seen here.
What we want to do in this example is to interact with our namereg-contract on the Blockchain via a HTML file using some browser. So the challenge becomes, how to close the bridge between this HTML file and the full node, for example the pyethapp node on our local machine.
What we need to do is to open our node to potential listeners by opening a JSON-RPC endpoint. Each client has a different default endpoint and different options to open them. The Python client opens this endpoint by default.
On the other side, we need to specify in our HTML file how it could become such a listener. This is (most ordinary) done using the Ethereum compatible JavaScript API - web3.js.
> mkdir NameRegEx
> cd NameRegEX
> npm install web3
> cd web3
Open a Python client using the '-c jsonrpc.corsdomain="http://localhost:8000"' option.
Create HTML file
<script type="text/javascript" src="../dist/web3.js"></script>
<script type="text/javascript">
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("http://localhost:4000"));
</script>