Create Your Own Marriage Contract

Prerequisites:

  • geth
  • An Ethereum account with some ether in it
  • Google Chrome


Navigate to this website.

The Solidity Online Realtime Compiler is a powerful tool that allows you to design, test, and deploy Ethereum contracts.

New to Ethereum? Try visiting this guide before moving forward.

Solidity Realtime Compiler Website

Open geth

The online Solidity compiler has the ability to connect to running instances of your geth node through RPC and IPC. Below are the flags you need to add when you start geth in order to allow your node to communicate with the website.
geth --unlock 0 --rpc --rpcport "8545" --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --rpccorsdomain "http://chriseth.github.io" console
If you'd like to have access to the geth console in a second command prompt window, open another console window and enter geth attach to attach that console window to your geth instance.
You may want to make a script so you can easily open your geth console. I accomplished this on my Windows system by creating a file called geth_unlocked.cmd which opens my geth console.


geth Script

Connect to Your Node Through RPC/IPC

Back at the Solidity Compiler website, we want to connect to our geth node over either RPC or IPC. Most people will want to connect over RPC. Click the Cube icon. Change the address and port in the "Web3 provider input" box to match the flags you set to launch geth. If you used the previous step to launch geth your address and port should be http://localhost:8545.

Online Solidity


A dialog box may pop up warning you if you want to connect. Click "OK".

Warning



Create Your Contract and Call Your Contract Functions

Click the red "Create" button on below your node connection settings. Your transaction will soon be mined (normally within 30 seconds) and your public variables (in blue) and your functions (in red) will appear below. Add information to the function calls to create your marriage on the blockchain. Note that Ethereum doesn't always understand the difference between a string and a hex value, so this online compiler differentiates the two by using quotes. If you want to submit a string, surround that string in quotes. For the time values you will need to use a converter site like this to convert your date and time entires to Unix epoch time. Once you have entered the data you want to send to Ethereum, click on the red function buttons that you have data entered for. This will create and push a transaction to the Ethereum network.


Online Solidity


Explore Your Raw Data

Once the transactions are mined, a transaction receipt will appear under the function. You can also click on the blue variable buttons to view the state variables that have been changed in the contract (many of them will come back as hexidecimal and will need to be converted to ASCII values to view properly).

Online Solidity

If you scroll further down, you will see the events that were produced because of the functions you called.

Events


Look at your geth window. You can see that right after you submitted your transactions they were added into blocks and mined.


geth Transactions


View Your Contract Data on My Site and A Blockchain Explorer

Navigate back to the online Solidity compiler and copy the contract address and all of the text in the "Interface" box to a text editor. The contract address is a unique address that identifies your contract on the blockchain based on 3 things: the contract code, your Ethereum address, and the number of times you have sent transactions from your Ethereum address (a.k.a the nonce). The text in the interface box is called the ABI - Application Binary Interface. It is used to map your variables and functions you want to call in your web app back to the contract. It is the interface layer between your high level Dapp and the low level Ethereum blockchain code.
Navigate to my Ethereum marriage website. In the box marked "Contract Address" enter your contract address. Enter your ABI information in the ABI box. After making sure you are connected to geth through the website, click the green button to see your marriage information you added to the blockchain. If you'd like to see more details about your contract on the blockchain, click on the dark blue button that says "View smart contract on the Ethereum blockchain".


Marriage Site

Want to learn more about Ethereum? Check out the documentation! ยป