Skip to content

Issue Your First Ethereum Transaction

Now that you have an Ethereum environment with some active nodes, it's time to deploy a basic smart contract and issue some transactions.

Create a Contract project

We'll start by leveraging Kaleido's Smart Contract Management component. This feature provides the collective business network with a transparent and auditable source code management utility. It delivers decisive mappings of your on-chain transactions and state changes directly back to your business logic. Additionally, it simplifies Ethereum transaction submission and application development by providing clean RESTful interfaces for interaction with your smart contract methods. No custom programming or blockchain expertise is necessary, and otherwise esoteric features of the protocol such as a nonce management and type mapping are removed from the equation. Simply upload some solidity code and Kaleido will provide an interactive Swagger interface along with downloadable API specifications for click button simple interaction and swift application development.

  • Navigate to your business network dashboard and click on the Shared Assets tab.
  • Select the Contract Projects component within the Shared Assets class.

First Contract Project

  • Click the CREATE CONTRACT PROJECT button in the middle of the screen.
  • Stay on the Ethereum tile and click NEXT
  • Provide a name for your Contract Project. We'll use Simple Storage for this example.
  • Click on the Managed Compilation from Github option. Kaleido also allows you to directly supply bytecode and an accompanying binary interface. However, we want to avoid compilation procedures and any unnecessary complexity, so we'll just import some basic solidity code from Github and let Kaleido do all of the heavy lifting.
  • Click FINISH to create the project namespace.

Contract Project Details

  • At the moment this is simply an empty contract project namespace with an "import from Github" configuration. We now need to populate it with some source code. Click the NEW COMPILATION button in the upper right portion of your screen.

New Compilation

Now we need to populate the required fields in order to generate our first compilation. We're going to use Kaleido's publicly available SimpleStorage smart contract for this example. It's a trivially simple piece of source code, with a single uint global variable - storedData - and two methods - set and get. We only need to supply arguments for the version of our compilation and the URL to the source code. Feel free to copy and paste the two strings below.

  • Description/Version: v1 ss
  • Github URL to solidty: https://github.com/kaleido-io/kaleido-js/blob/master/deploy-transact/contracts/simplestorage_v5.sol

There is only a single smart contract within this solidity file, so we can forgo the Contract to be compiled field. And this is a public Github repository, so we don't need an access token. Let Kaleido autodetect the compiler in the source and leave the EVM engine as Constantinople.

  • Click FINISH to generate the compilation of SimpleStorage.

Compilation Config

The process should take roughly 5-10 seconds to complete. After which you're left with on a screen displaying the compilation details: the bytecode, the binary interface, the embedded developer docs, the URL of our source and even the git commit hash! Every on-chain contract that leverages this compilation will be mapped directly back to this source of truth.

Now is the fun part. We are going to take this compilation and turn it into a set of Open APIs for easy deployment and even easier reads and writes against our Ethereum blockchain.

  • In the top right portion of your screen click the up arrow to promote this compilation to your existing environment.

Promote Compilation

  • Promoting a compilation results in the generation of Open APIs for the smart contract methods. We refer to this as an API Gateway in Kaleido. Think of a compilation as having a one-to-one mapping with a Gateway API.
  • Provide a name for the Gateway API, for example simplestorage.
  • Click FINISH to generate and promote the API to your environment.

Name Gateway

  • Now you're brought into the Gateway APIs view within your environment. And specifically within the simplestorage Gateway API.
  • Our next task is turn these APIs into an actual on-chain smart contract deployment. As of now all we've done is generate a compilation and a subsequent Gateway API for the compilation.
  • Click the Deploy Instance button to turn your Gateway API into a proper smart contract instantiation.

Deploy Instance

  • This will open a new modal where you will be tasked with selecting the node that is going to receive the deployment transaction. Select one of your nodes from the dropdown menu.
  • Next click the View API button

Select Node

  • Choose Click here to View API in a new tab which will open a new window with an interactive Swagger interface.

View API

  • This Swagger interface will only contain a single REST method, a root POST method that allows you to instantiate the Gateway API and turn it into an on-chain smart contract instance.
  • Expand the root POST method to see the available Kaleido submission parameters.
  • This transaction paradigm leverages the Kaleido REST API Gateway for simplified interaction with your Ethereum blockchain, and it also exposes a number of parameters for further customization of your smart contracts and transaction submission approaches. The nuances of the REST API Gateway are out of scope for this quick start, but we'll take a look at a handful of important parameters.

Swagger Interface

  • kld-from - The Ethereum address that is going to sign the transaction. By default you receive the existing Ethereum account on the node through which you're viewing this API instance. Any key held in a Kaleido managed wallet (e.g. HD Wallet) or integrated utility (e.g. Cloud HSM) can be passed to this field.
  • kld-sync - Synchronous (true) or asynchronous (false) transaction submission. Synchronous requests will wait until the transaction is mined before returning a transaction receipt. Asynchronous requests simply wait for an acknowledgement from the Kafka Requests Topic and return almost immediately.
  • kld-register - Allows for arbitrary names to be applied to smart contract instances as opposed to hexadecimal address representation. Human friendly naming techniques can be leveraged for easy identification across the business network. Also useful for easy delineation amongst multiple instances deployed against the same Gateway API.

The Body Data is the input payload for the transaction. In our case we need to initialize our smart contract with a value because the constructor requires an argument to be passed.

  • Add a human friendly name for your smart contract. For example, ss123
  • Overwrite the placeholder syntax in the JSON body, and supply an uint. For example, 12345
  • Click TRY to invoke the root POST method and deploy the smart contract

Swagger Instantiate

  • Look for a 200 status code and a response payload containing the details of your deployment (timestamp, blockhash, transaction hash, gas, etc.)
  • Now close this Swagger Interface to return to the Gateway APIs view within your environment. If the deployment was successful, you will see your smart contract listed beneath the Contract Instances row.

Contract Instances

  • Use the dropdown next to your instance to interact with the smart contract (e.g. get & set) or view the contract details to see additional information and transaction-specific data.
  • For an interactive walkthrough that performs the same steps take a look at the Smart Contract Management and REST API Gateway product videos.