Arweave.news

A Look at RedStone Contracts: A New SmartWeave SDK Implementation

0 385

SmartWeave is Arweave’s smart contract system – a unique idea for secure blockchain programs which can be written in JavaScript and cost a trivial amount to compute compared to Ethereum and other alternatives. An original innovation that sets SmartWeave apart from other smart contracts is that contracts can be lazily evaluated – the burden of contract execution is offloaded to the client, which makes them much cheaper to deploy and interact with.

RedStone has been keen to innovate on SmartWeave’s first iteration to improve performance and increase the efficiency of the RedStone Oracles. After initially tweaking the original code, the team decided to rewrite it from scratch, and create RedStone Contracts.

As RedStone’s team was developing infrastructure using Smarweave, we were facing recurring obstacles on our way. After a few workarounds we ended up with an SDK that was far enough from original code that we decided to make it a separate stream.We called it RedStone Contracts. Peter (Discord: redstone-ppe) is the initiator of this idea and the core developer behind it. – Marcin, Head of Growth @ RedStone

RedStone Contracts are a new approach to SmartWeave with a range of performance, usability, and testing improvements with an updated SDK from Arweave-based oracle RedStone. SmartWeave is Arweave’s native smart contract engine, which can be written in JavaScript or TypeScript and used for anything from NFTs to entire application backends.

RedStone Contracts power RedStone’s whole product, and as one of Arweave’s heaviest users – responsible for thousands of transactions daily – so has a great incentive to make improvements.

Introducing RedStone Contracts

RedStone Contracts aim to address performance issues with the current implementation by removing unnecessary calls to Arweave and adding support for a caching layer. KYVE, for example, implemented caching using smart contracts with this feature. RedStone provides an example here.

By breaking the core protocol interfaces down into individual units, the RedStone Contracts’ code will be easier to test and build out as new features – like an isolated execution environment and better debugging tools – are developed.

Other quality of life features have been added like improved naming conventions, enhanced and fully configurable logging, better documentation, and clearer definitions of function arguments.

RedStone Contracts is a backwards-compatible SDK, meaning that all current SmartWeave contracts can use it instead of the original SDK provided as part of smartweave-js. It introduces new concepts and methods with their own namespace, so it’s necessary to migrate to use the new method calls and syntax provided. RedStone provides a migration guide to help translate your existing SmartWeave-based code to use the RedStone Contracts SDK.

RedStone Contracts uses an object oriented programming design (OOP), to make it easier to test and expand with new features.

Developers can already add Redstone’s Contracts to their projects: yarn add redstone-smartweave

RedStone’s smart contract best practices

As well as concrete improvements to the SDK, RedStone has published a guide explaining how to build a contract like LOOT, alongside best practices for testing contracts to ensure they are bug free. One problem at the moment with the old tooling is that the exact reason why a contract interaction failed is not easy to surface. 

In RedStone’s LOOT contract tutorial, the team explains how to write simple Node tests or use JEST, and provides examples here.

The road ahead

In the next phases of Redstone Contracts, the team plans to focus extensively on unit tests, creating a full stacktrace of contract calls (for debugging purposes), implementing isolated execution environment, adding ability to modify external contract state g and the ability to break contracts up into separate classes and interfaces for a more OOP approach. See the full roadmap here

Leave A Reply

Your email address will not be published.