This add-on is operated by Object Frontier Software
Enterprise Blockchain Made Easy.
Last updated 02 November 2018
The Blockchain add-on is currently in beta.
Table of Contents
ObjectFrontier Blockchain is an add-on that installs a private Ethereum blockchain instance in your Heroku environment. Use the OFS Admin App to:
- Configure your private network
- Compile and deploy solidity-based smart contracts
- Create new application experiences
- View each block in the chain
OFS Blockchain provisions a default master account and preloads private tokens to get you started with developing your blockchain applications and smart contracts.
- A new Heroku app with no code deployed (click here to create one, or use the Heroku CLI)
Provisioning the add-on
Run the following Heroku CLI command to provision OFS Blockchain:
$ heroku addons:create blockchain:test -a blockchaindocumentation Creating blockchain:test on ⬢ blockchaindocumentation... free Your add on is being provisioned Created blockchain-encircled-58201 as BLOCKCHAIN_LOAN_APP_URL, BLOCKCHAIN_SERVICE_URL Use heroku addons:docs blockchain to view documentation
blockchain:test plan is provisioned, OFS Blockchain is shown in the “Add-ons” section of your app under the “Resources” tab:
Configure your private blockchain
From the Resources tab of your Heroku app, click the OFS Blockchain add-on to launch the Deployment Wizard:
Click Provision now for [your app name].
This launches an OAuth prompt requesting access to your Heroku app to install the OFS Private Blockchain master instance:
Click Allow to proceed with the full installation.
After OAuth succeeds, you are redirected to your Heroku app’s Overview page. There you can see the private Ethereum image build in progress:
If you’d like to see what’s happening during the Ethereum build & deploy process, you can observe build logs as follows:
After a successful build, deployment of the private Ethereum instance starts automatically. You can also view the deployment logs by clicking the View logs option under More:
After a successful deployment, you will see the following:
As noted in the log viewer, please wait about 5 minutes before accessing the OFS Blockchain Admin Console and starting to deploy smart contracts. The Ethereum DAG generation is still happening at this point and will be completed within the 5-minute period.
During the build process, you might encounter an R14 (Memory Quota Exceeded) error:
If you do, it’s probably because you need to use a
performance-m dyno for your app’s
web process. Fix the error from your app’s Resources tab like so:
Blockchain Admin Console
Click Open app in the Heroku dashboard to view your blockchain administration console. You can also open it with the following command from your app’s root directory:
$ heroku open
Use the default “admin” account to login. un:admin pwd:admin
Default account with preloaded tokens
Add new admin account
Add a peer node
Use this feature to add another node as a peer to your blockchain network. The steps are as follows:
- Go to the admin console of the node you would like to add as a peer.
- View the node’s Admin Node Info as shown above.
- Copy the node’s enode URL.
- Paste the URL into the eNode field of the Add Peers form:
- Click Add as peer.
The two nodes will start synchronizing the blockchain.
Tokens are mandatory to deploy smart contracts from an account.
Lock and unlock accounts
Provides an option to lock/unlock an account. Only an unlocked account can be used to deploy smart contracts.
Newly added accounts are locked by default.
Start and Stop Mining
Smart contracts can be deployed only when there is a mining node in the network. By default, your node will be started as a mining mode. You can start/stop mining from the admin console.
Mining will add new tokens to the default account. You can then transfer tokens to the accounts you desire.
The admin conosle is prepackaged with a demo smart contract for a Loan Application.
Upload a Solidity file
Upload a Solidity smart contract file to compile and deploy to blockchain.
Constructor arguments cannot be passed dynamically yet.
Compile your contract
Deploy the compiled contract to your blockchain
Contract ID and Application Binary Interface (ABI)
You will need them both for developing DApps
Always displays the last 50 blocks.
Filter Blocks with Transactions Only
This helps you explore blocks that have transactions in them. For example, you can view a block that has the transaction deploying your smart contract and view the transaction input - the byte code of the input data
Blockchain Data Persistence
The Ethereum platform typically uses a filesystem to store its blockchain transactions, however Heroku Dynos each contain their own ephemeral filesystem. This means that during ‘dyno’ restarts, files stored in the file system will be removed. To address this need to maintain the blockchain transactions the
OFS blockchain add-on provides an on-demand backup feature. This enables you to ensure all private blockchain data is saved and restored after
dyno restart events.
The blockchain Backup feature uses the
Heroku Postgres Add-On so be sure to add this by navigating to the Resource tab of your Heroku app and selecting the appropriate plan.
After adding the
Heroku Postgres Add-On to your app, the
web dyno will restart automatically. Once it’s restarted, refresh your OFS Blockchain Add-On Admin App. You should now see the Backup button on the right corner of the screen.
Now that this is enabled, you may now backup your blockchain data any time by clicking this Backup button. Whenever the Heroku
dyno is restarted, the most recent backup will be restored automatically and you can verify the restore using the block explorer tab in the OFS Blockchain Add-On’s Admin Console.
Deploying the Demo DApp
The demo loan application has the following entities:
- The applicant
- The loan program
- The loan
All the above entities are deployed as smart contracts in the blockchain.
The applicant smart contract is an immutable record of the applicant details that can be passed around to vendors and partners involved in loan processing.
The loan program is a Decentralized Autonomous Organization (DAO) deployed by the bank or the loan provider.
The loan is the actual loan offered to the applicant. The entire service lifecycle of the loan, including credit status, approval, and payments are all handled through its smart contract functions.
Complete the following steps to deploy the loan program.
Step 1: Compile the loan program
The admin console is prepackaged with a sample smart contract that can be used with the demo app. Specify a name for the loan program and compile the contract:
Step 2: Deploy the loan program
Step 3: Copy and store the contract ID after deployment
Step 4: Deploy the loan demo DApp to Heroku
Deploying the loan demo DApp to Heroku is simple. Just click the Launch Demo Loan App button, which navigates you to the Heroku app deployment page:
You must set the following fields before deploying the app to Heroku:
- The app name (set to whatever you like)
BLOCKCHAIN_SERVICE_URLconfig var. Specify the URL of your OFS Blockchain app, with
/blockchainappended to it (e.g.,
LOANPROGRAM_CONTRACT_IDconfig var. Specify the smart contract ID of the loan program you deployed in Step 3.
Click the Deploy App button to initiate the build and deployment:
After successful deployment, click View:
The loan application demo DApp
The loan program you deployed through admin console
Manage/Service the loan
Removing the add-on
You can remove OFS Blockchain via the CLI:
This will destroy all associated data and cannot be undone!
$ heroku addons:destroy blockchain -----> Removing blockchain from sharp-mountain-4005... done, v20 (free)
All OFS Blockchain support and runtime issues should be submitted via the Heroku Support channels. Reach out to firstname.lastname@example.org for other questions and service offerings.