Browsed by
Category: cryptocurrency

Creating ERC20 Token on Ethereum Network

Creating ERC20 Token on Ethereum Network

With the ICO craze, I have wondered the amount of effort required to launch my own ICO. This endeavor is for academic purposes only of course. It turns out creating a fully functional ERC20 token that can be sent around the network is pretty trivial. You can create your own within an hour and about 10 USD. Credit to the original author this post is based on. This walkthrough will highlight the import aspects of maxnachamkin tutorial and does not attempt to completely rewrite it.This is the start of a series where I will investigate the creation of assets on other networks, ie BitCoin and Ripple.

1. Contract Attributes

To create the token, we will be creating a smart contract that will be deployed to the ethereum network. The first step is to determine how you want your token to behave.

For first out, I am starting off with a simple token. The token will be completely premined with all tokens being sent to the contract creators address (me). No decimal points, so tokens must be transacted in whole units. The source for the smart contract that will achieve this is here.

Contract NameGrimmjow8Token
Display NameGrimmjow8 Token
Total Supply10 million

FUTUREImplement a mineable token

2. Deploy to Testnet

The hard part is done. We now will test out the token on the test net before deploying to the main net. Below is a high level of the steps required to deploy to the test net:

  1. Download and create a wallet using MetaMask
  2. Fund your new test wallet utilizing the MetaMask faucet
  3. Compile and publish the token smart contract to the Ropsten test network using browser-solidity
  4. Confirm contract creation on
  5. Add contract to MetaMask to display newly created tokens
  6. Import MetaMask wallet private key into a wallet that supports sending tokens, such as myetherwallet
  7. Transfer tokens between addresses

Download MetaMask

Download MetaMask. MetaMask is an online wallet that allows the creation and publication of tokens easily to the network.

  1. Make up a password to create your first address
  2. Make sure to change the network to the Ropsten Test net
  3. Document the public and private key for this first address

NOTE: The address generated is valid on both the test and main net. Be careful with your private key from the test net in the event you use the same address to generate the tokens on the main net.

Fund Wallet

After creating the wallet, we need to fund the wallet so that we can create the contract and send tokens.

With the test net selected, click ‘Buy’ to get some either. You should be presented with a link to the MetaMask faucet. From there, you can request to have some ether sent to your wallet.

Compile and Publish

With your wallet funded, we just need to compile and publish the contract to the blockchain.

  1. Load the Solidity Remix Compiler
  2. Copy and paste smart contract code into editor
  3. If you have not already, update the contract details near the bottom the contract file
  4. On the right panel, disable auto compile
  5. Click ‘Settings’ menu item, change compiler to ‘v0.4.18+commit.9cf6e910’, deselect ‘Enable Optimization’
  6. Click ‘Compile’ menu item, click compile. Hopefully, the contract compiles with no errors
  7. Click ‘Run’ menu item, populate the ‘At Address’ with your MetaMask wallet address and click ‘Create’
  8. When presented with a popup to confirm the transaction, click ‘Submit’

Now you just wait for the test net to verify the contract creation.

Confirm Contract Creation

Search for your MetaMask address within You should have a ‘Contract Creation’ transaction. Clicking the ‘To’ link will take you to the contract information page. From here you can upload and verify your contract source code with etherscan. If you want the full experience, you can create a website and get your token added to exchanges and the etherscan registry.

Test Sending Tokens

The final step is to try to send some of these tokens to another address.

  1. Create a second wallet within MetaMask
  2. Export the private key of your first address (current owner of all tokens)
  3. Open myetherwallet
  4. Import your private key
  5. Click ‘Send Ether & Tokens’ menu item
  6. On the right panel, click ‘Add Custom Token’ button and enter the contract address
  7. Available tokens to send should now be viewable. Enter an amount to send and change the type from Ether to your token type
  8. Click ‘Generate Transaction’ and ‘Send Transaction’

The transaction should be broadcast to the network. You should be able to see your tokens appear in your send address within the MetaMask wallet.

3. Deploy to Mainnet

The steps to deploy to the main network are exactly the same as deploying to the test net. The only differences are the following:

  1. Must change the network to Main within MetaMask
  2. Transactions and contracts must be view on the main explorer
  3. You will need to actual ether (ie through Coinbase)

For those interested, here is a link to the Grimmjow8Token created during this exercise.

4. Conclusion

The process for creating an ERC20 token was incredibly easy. Within about an hour, I had the token deployed to the main net for only about 10 USD. Next steps will be to look at creating more complex smart contracts (including a mineable one) and attempt to create assets on other networks.

NOTE: The actual cost of create a token on the mainnet is the transaction fee.

Using ripple api to query network and address information

Using ripple api to query network and address information

Hey Everyone,

This will be a quick post.

It’s been awhile since I made a post on some of the interesting challenges I’ve faced on my side projects. This is a continuation of my blockchain restapi work first mentioned here: dash-node-error.

Not just limiting myself to running nodes, I wanted to experiment with using existing apis. I started off with the Ripple (XRP) api. The main two pieces of information I needed from the chain were a list of transactions and an address’ balance.

Perusing through the api, there appeared to be two existing apis that would suit my needs:

Get Account Balances - GET /v2/accounts/{:address}/balances
Get Account Transaction History - GET /v2/accounts/{:address}/transactions

The balances endpoint worked as expected. Below is an example url and response:


      "result": "success",
      "ledger_index": ,
      "limit": 200,
      "balances": [
          "currency": "XRP",
          "value": "200"

The transactions endpoint; however, had incomplete data. Example url:

I noticed the transaction inputs did not add up to the account balance. After a bit of digging, the only thing I was able to find was that transactions were missing from exchanges that used sidechains. The solution for me was to merge data from the /payments endpoint. This allowed transaction data to mirror balances.


      "result": "success",
      "count": 3,
      "marker": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn|20140910232220|000008803725|00001",
      "payments": [
         "amount": "1.0",
         "delivered_amount": "1.0",
         "destination_balance_changes": [
             "counterparty": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
             "currency": "USD",
             "value": "1"
         "source_balance_changes": [
             "counterparty": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
             "currency": "USD",
             "value": "-1"
         "tx_index": 1,
         "currency": "USD",
         "destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
         "executed_time": "2014-06-02T22:47:50Z",
         "issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
         "ledger_index": 6979192,
         "source": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
         "source_currency": "USD",
         "tx_hash": "7BF105CFE4EFE78ADB63FE4E03A851440551FE189FD4B51CAAD9279C9F534F0E",
         "transaction_cost": "1.0E-5"
Dash node address balance querying error – ‘No information available for address’

Dash node address balance querying error – ‘No information available for address’

1 Solution

For those weary Googlers looking for the solution to the above error from the dash-cli.  When starting the dash daemon, the -addressindex=1 option must be set. If the blockchain has already been downloaded, you can enable address indexing by following the below steps:

  1. stop the daemon
  2. restart the daemon with the addressIndex and reIndex option enabled:
    dashd -rpcallowip=::/0 -reindex=1 -addressindex=1 -txindex=1
  3. wait for the blockchain to reindex

NOTE: enabling address indexing will increase the dash disk usage from about 3GB to 5GB (as of time of writing).

2 Problem

I recently starting working in blockchain and cryptocurrency development. My first hands-on project involved setting up a RESTApi that would directly talk with a Dash node daemon through the dash-cli command. I know, I could have just used an existing api implementation, like insight-api-dash, but that would be too easy.

I set up a dash node using a modified Dockerfile from docker-dashd. However, testing the node with the sample command:

dashd getaddressbalance '{"addresses": ["XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"]}'

Resulted in the error message ‘No information available for address‘. Google searches resulted in no solutions; I decided to delve into the dash source code.

3 Discovery

After downloading the source and searching for the particular error string, I found the error getting returned from the getaddressbalance rpc procedure (rpcmisc.cpp):

for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
    if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) {
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");

Interesting…but not really useful for figuring out why the procedure wasn’t returning the expected data. I needed to dig a little further, so I looked into the GetAddressIndex function. The function performed a few precondition checks that potentially would log an error message. I had previously checked the docker logs for the container but must have missed any meaningful messages. I took a closer look at the logs and found an interesting error message, ‘address index not enabled‘.

I was getting close and realized I probably missed an option during the initial start of the daemon. With more than 100 options to use, I wasn’t surprised. A few more minutes of digging and I found the answer I needed in main.cpp:

fAddressIndex = GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX);

Turns out I need to explicitly enable addressIndexing to perform the getaddressbalance and other address specific queries.

4 Solution

Once the problem was known, the solution is fairly simple. I just needed to restart the dash daemon with address indexing enabled.

Take #1, I stopped the daemon, added the option to the command, and restarted. I attempted another getaddressbalance and I received the same error message. Confused, I took a look at the logs and was greeted by an error message stating I needed to specify the -reindex=1 option for address indexing to take effect.

Take #2, I stopped the daemon, added the two options, restarted the daemon, executed the query and success!