This tutorial shows you how to make a payment in Ether based on the outcome of the execution of a Smart Clause®.

No programming skills are required for this tutorial, however, to use your own test account you will need to create an Ethereum account on the Rinkeby test network, request Ether for the account using the Faucet and then extract the private key for the account. See the documentation here for help.

Infura Sign-up

To be able to move Ether from one Ethereum account to another Clause needs access to the Ethereum network. For this tutorial we will use the INFURA service to access Ethereum.

Clause uses an Ethereum RPC URL to access the network, so you can use your own or a 3rd-party Ethereum node if you wish.

Sign-up for Infura access (free accounts are available) using the Infura website.

Create a new Infura Project

Create a new Infura project, giving it a memorable name, such as "Clause Tutorial".

Click the "View Project" link to see your project id, secret and endpoints for the various Ethereum main net and test networks. You will need these later.

Create a Rinkeby Network Account

In this tutorial we will move Ether over the Rinkeby Ethereum test network.

Follow the instructions here to create a Rinkeby account and request some test Ether from the Faucet.

You can use Etherscan for Rinkeby to view the transactions on the network and the Faucet for Rinkeby to request additional Ether for testing.

Get the private key for your source account

We will be configuring Clause to move Ether from one Ethereum account (source) to another Ethereum account (destination). To move the Ether from the source account we need the private key for the source account.

Run the getPrivateKey utility to retrieve the private key for your source account.

To test your configuration by making a transfer on the command line you can use the transferEther utility.

The private key for an account gives someone complete control of the Ethereum account, including removing all the of the Ether. You should treat private keys with care and ensure you only have enough Ether in the account for the purposes of the smart legal contract. I.e. treat it as a "hot wallet" for this specific contract.

Create a Smart Legal Contract

Create a new smart legal contract via the Clause dashboard and add a Smart Clause that emits a Payment Obligation, for example, Fragile Goods.

Create an Action Flow with an Ethereum Transfer Step

Add an Action Flow to the Smart Clause, and then add a Ethereum Transfer Step to the flow.

Set the From Account, To Account, Private Key and RPC URL.

Leave the Gas Limit and Gas Price parameters empty (they are optional and will be set automatically, if not specified).

The WEI Value parameter should be based on the Payment Obligation emitted by the Smart Clause. Set the value to:

 {{% step[0].output.amount.doubleValue %}}

Note that in this case we assume the Smart Clause is emitting values in wei. If the Smart Clause is emitting values in USD we can use an additional HTTP Step to call a USD to Ether currency conversion service, such as : and then use a JSON Transformation Step to compute the USD amount in wei.

Example Ethereum Transfer Step configuration

Sign the Contract

Obligations are only processed for signed contracts, so you should now sign the contract by either adding signatories and pressing the Request Signatures button, or by pressing the 3 dots to the right of the Request Signatures button and then selecting Sign Offline.

Trigger the Smart Clause

Add a Trigger Flow and HTTP Trigger, then using the trigger URL and authentication token you can trigger the Smart Clause by sending a JSON POST request, using Postman, Insomnia or cURL, for example.

Here is a JSON body payload for the Fragile Good Smart Clause, which will cause 995 Wei to be transferred from the source to the destination accounts.

curl --request POST \
  --url \
  --header 'authorization: Bearer MY_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
    "$class": "io.clause.demo.fragileGoods.DeliveryUpdate",
    "startTime": "2019-07-31T09:43:20.742-04:00",
    "finishTime": "2019-07-31T09:43:20.742-04:00",
    "status": "ARRIVED",
    "accelerometerReadings": [10.5],
    "transactionId": "28cd4460-b399-11e9-a415-2f2abeed0243",
    "timestamp": "2019-07-31T09:43:20.742-04:00"

View the Ethereum Transaction

Assuming you're are using the Rinkeby test network, you can view your transaction by visiting and searching for the source account. You should see an OUT transaction for the account. Clicking on the transaction will display the details:

Details for an Ethereum transaction created by a Smart Clause