Use of Ricardian Fabric with Smart Contracts

Peter Horvath
3 min readSep 12, 2021

In the previous article, I explained the use of Ricardian Fabric and how to create simple agreements on the Arweave blockchain. Check it out here.

In this following article, I will explain it’s use together with a smart contract written in Solidity.

source: https://iang.org/papers/intersection_ricardian_smart.html

Smart contracts today exist on a myriad of platforms but there is one thing that is mostly common in them. They contain only computer code.

Code is hard to read for people who don’t work with it and this leads to problems down the line as more and more people get into Crypto and DeFi.

Crypto is forever but the agreements behind it are not.

How can we change that? Let me demonstrate with a simple coding pattern first, I will write a smart contract and then the agreement for it.

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract SimpleAgreements {

// A string to store the url of the terms and agreements
string terms;

struct Agreed {
bool signedIt;
string arweaveTxId;
}

// A mapping between Eth addresses and tx Ids on arweave
mapping(address => Agreed) signedAgreements;
constructor(string memory _terms){
terms = _terms;
}
function agree(string memory arweaveTxId) public {
signedAgreements[msg.sender].arweaveTxId = arweaveTxId;
signedAgreements[msg.sender].signedIt = true;
}

function getTerms() public view returns (string memory){
return terms;
}

function didSign() public view returns (Agreed memory){
return signedAgreements[msg.sender];
}
function deFi_stuff() public{
require(signedAgreements[msg.sender].signedIt == true,"You need to agree to the terms");
// Do deFi_stuff :)
}
}

The above smart contract is just for demonstration purposes. Let me know if you spot bugs.

In the above contract, you store the link for the agreement in the terms string which you assign in the constructor and provide a way for users to agree with it.
The function didSign() can be used for validation on the Front end or in other contracts to make sure the address interacting with it has signed the agreement.
Finally the deFi_stuff() function is for demonstrating purposes only, could be anything.

Now let me show you the agreement stored on arweave for this.
It’s deployed here.

The beautiful thing about Arweave is, that once the transaction is accepted by the network, the links will never break.

When creating something similar to the above linked agreement protocol, the use of the redirect feature is recommended, so after acceptance you are able to capture the Arweave transaction Id on your DeFi front end automatically.

With this knowledge, I hope you understand a little better how to use Ricardian and Smart contracts together.

Ricardian Fabric is a useful tool for a developer to protect himself in case of hacks or to define the assets in ERC-20 or NFT contracts so they are categorizable by regulators. You can help them differentiate assets from securities.

That’s it for now. Thank you for reading and check out ricardianfabric.com for the latest version of the MVP and more things coming soon!

--

--