HowTo – Connect Blockchains with APIs and Anypoint Platform

October 26 2017

mulesoft blockchain

Blockchains are slowly creeping their way into the enterprise and gaining acceptance. As Harvard researchers reveal, “No matter what the context, there’s a strong possibility that blockchain will affect your business. The very big question is when.” But what are Blockchains?

Here’s a primer that gives a pretty good overview. But in short, a Blockchain is a digital transaction ledger that, instead of resting with a single provider, is shared among a distributed network of computers. Each transaction is shared and continually reconciled across the network.



So where does MuleSoft come in when considering Blockchains as part of your enterprise? Through our API-led connectivity approach, Anypoint Platform provides a holistic way to connect Blockchains through reusable, built-for-purpose APIs. And in this blog post, I will show you how MuleSoft gives you granular control around sharing data and monitoring transactions within and outside the Blockchain. The guide provides a way to setup your own Blockchain using MultiChain and deploy a pre-built Mule application with an API to expose those capabilities.

In this guide, I provide a public AWS AMI image for you to start up and play around with Blockchains and learn about nodes, assets, orders, and streams. If you have MultiChain already setup, you can jump to Step 3 and configure it for your node.

The image has two MultiChain Blockchain nodes installed and includes the Web Demo Interface that allows you to play around with the Blockchain environment.

Additionally, you can start up the MultiChain Explorer that allows you to read the MultiChain block file.

Steps to Creating Blockchain with Anypoint Platform

1. Create and Start Blockchain

In this step, you’ll start an Amazon EC2 instance using an AMI that has two MultiChain nodes installed. Once started, you’ll create a new chain on the instance called ‘mulechain-core’. When you spin up a new instance, you’ll connect to this node to create a Blockchain.

1.1 –  Login to your AWS account.

1.2 – Click on Services and click on EC2.

blockchain mulesoft

1.3 – Click on AMIs on the left-hand navigation bar, change the drop-down to ‘Public images’ and search for ami-da8347a0. Then check the box for the AMI and click on Launch.

1.3.a Keep the t2.micro instance type and click on ‘Review and Launch’

blockchain mulesoft

1.3.b Before launching the instance, click on ‘Edit security groups’

blockchain mulesoft

1.4 – In order for you to access the machine from a browser, you’ll need to open some ports. Create a new security group and expose the following inbound ports: 80, 22, 4286 – 4287, and 2750. Set the source for each to be either ‘Anywhere’ or ‘My IP’ and then click ‘Review and Launch’

blockchain mulesoft

1.5 – Click Launch and then either create a new key pair or use your existing key pair.

blockchain anypoint platform

1.6 – Connect to the AWS instance using the following command in a terminal window and being sure to reference the location of your .pem file. – ssh -i “<your .pem file>”

blockchain mulesoft

1.7 – Run the following command to start the core chain: multichaind chain1 -daemon -datadir=/home/ec2-user/node1

blockchain mulesoft

1.8 – Once the node has been started, start the other node: multichaind chain1 -datadir=/home/ec2-user/node2 -rpcport=4333 -port=4335 -daemon

blockchain anypoint platform

1.9 – Open a new tab and navigate to the URL for the instance using the public URL of the server: e.g. Then click on the link for the node.

blockchain anypoint platform

1.10 – That’s it for the Blockchain setup. You can play around with the Web Demo interface and add and send assets. The interface is only configured to interact and browse through one node.

blockchain anypoint platform

2. Run MultiChain Explorer

MultiChain Explorer is a free block chain browser for MultiChain blockchains.

2.1 – Back in the Terminal, navigate to the following folder: cd ~/multichain-explorer-master/

2.2 – Run the following command: python -m Mce.abe –config chain1.conf

blockchain mulesoft

2.3 – Switch back to Chrome and open the following URL: http://[EC2 Public URL]:2750, for e.g.

blockchain anypoint platform

3. Deploy Mule Application

This step provides a Mule project with a defined RAML that wraps the MultiChain JSON-RPC API. Once deployed, you can play around with a small subset of methods and resources around the MultiChain API.

3.1 – Download the project from Github and unzip the file to a folder.

blockchain mulesoft

3.2 – Import the project in using General > Existing Project into Workspace in your Anypoint Studio.

blockchain anypoint platform

3.3 – Open the file and fill in the properties for the core node.


blockchain anypoint platform

3.4 – Open the multichain-api.xml file and run the project.

blockchain anypoint platform

3.5 – Open a new browser tab and navigate to http://localhost:8081/console

blockchain anypoint platform


Blockchain technology saw an increase in adoption and implementation in 2017 and we’ve only just started seeing new business applications. Smart contracts, supply chain auditing, and file storage are just a few of the up and coming applications of this technology.

By providing an API-layer over the Blockchains infrastructure, organizations move to this new disruptive technology gradually by exposing the components you need and having the ability to govern and monitor the usage of this endpoints.

What new business applications can you think of and build with Blockchains and the application network?


We'd love to hear your opinion on this post

6 Responses to “HowTo – Connect Blockchains with APIs and Anypoint Platform”

  1. Hi,
    I followed the complete blog in setting up the sample application. While Blockchain setup and Multichain Explorer setup are successful, am struck up running the mule project.

    I am getting the following error while invoking any of the APIs through the API Console –

    Message : Error sending HTTP request to .
    Payload : {“method”:”getinfo”}
    Payload Type : java.lang.String Connection refused: no further information
    at Method)

    Error sending HTTP request to .

    I tried using the below properties as indicated in the blog –


    I believe rpcport, rpcuser & rpcpassword should be the same and the only change is the public IP (rpchostip) which is based on the public IP of the EC2 instance running on AWS.

    Please help resolving the issue. Thanks in advance.

    • Hi Larsen,

      There’s a type in the instructions. The rpcport should be set to 4287 in the file. Once you change that, you shouldn’t see the error anymore.

      – Dejim

  2. The RPC user details were not valid for me.

    I found the details for in

    After that everything worked beautifully for me.

    Nice work!

  3. We can no longer see the AMI image in AWS. Should we be using a different image copy?

    • Hi Vijayan, have you checked Step 1.3? Make sure you’re searching for public images in AWS

  4. Dear Larsen,

    I am having good knowledge in Hyperledger Fabric ( Blockchain) . I am exploring option to Integration from Legacy system to Blockchain.

    Integration with SAP ERP
    Integration with Oracle ERP
    Integration with Various RDBMS
    Integration with Peoplesoft
    Integration with Ramco System
    Integration with Salesforce

    I read on mulesoft website that this integration tool is smart enough to connect with above system. So its possible that using mulesoft I can create a layer between Legacy system and Blockchain . If its possible then data from Legacy system to Blockchain will store and vice versa.

    Please validate my understanding so that I can start work on POC.