Skip to content

Erdstall SDK

Sebastian Stammler edited this page Jan 17, 2022 · 4 revisions

Erdstall TypeScript SDK

The Erdstall SDK lets any client or server application interact with an Erdstall network. Erdstall can be thought of as a sub-network to the Ethereum network to increase transaction throughput, decrease costs and offer almost instant processing of transactions (unlike the seconds to minutes one has to wait for blocks to be mined on Ethereum). More background information can be found in the respective README section.

Erdstall Architecture

At the heart of the Erdstall system lies a secure enclave program that runs inside a TEE (Trusted Execution Environment) like Intel SGX. The Erdstall operator is a server containing the TEE. The operator forwards messages between the Ethereum blockchain, users and the secure enclave and by the protocol is thus an untrusted message broker. The operator also deploys the Erdstall smart contracts and registers token contracts.

When users want to enter the Erdstall system with some on-chain Ethereum assets, they have to deposit those assets on the Erdstall smart contract. The operator watches the Erdstall main contract for those deposits and forwards them to the secure enclave. Once a users has deposited tokens into the Erdstall system, they can transfer and trade them freely.

A special case is off-chain minting. Depending on the configuration, either all or only white-listed users (like marketplace operators) are allowed to mint NFTs off-chain, in the Erdstall network. They don't need to deposit any assets prior to minting.

When a user wants to exit the Erdstall system to the Ethereum network, they can send an exit request to the operator. After a short waiting period, they will receive a so-called exit proof and can then, after waiting for a few more blocks, withdraw all assets on-chain, possibly minting NFTs on-chain that were previously created off-chain.

End-2-End Integration Test

The SDK's tests contain an end-2-end test, which also serves as a user guide on how to use the SDK. The API is fully described in file src/e2e/sdk_actions.ts. The end-2-end test harness can be found in file src/e2e/test_harness.ts. It operates on the actions described in sdk_actions.ts and shows how to interact with Erdstall. The end-2-end test itself is run in the repository's CI from file src/e2e/sdk_e2e.spec.ts, which just runs the test harness.

The end-2-end test is not self-contained as it needs a running instance of an Ethereum test blockchain (Ganache) and a running Erdstall operator.

Setup

We use yarn for package management. Run yarn to install the SDK's dependencies. The SDK's devDependencies contain the Ganache test blockchain. The npm package ganache-cli provides the respective command. Also run yarn build to transpile the TypeScript sources.

Our core Erdstall source code is currently not open source, so please contact us for your private access to binary versions of the operator. We provide a special walkthrough-operator which starts a test Ethereum blockchain using ganache-cli, deploys the Erdstall smart contracts to it and prefunds the accounts used in the end-2-end test with ether. It is specifically designed to be started from the end-2-end test.

Run

To run the end-2-end test, set the environment variable ERDSTALL_EXE to the path of the walkthrough-operator and run

ERDSTALL_EXE=path/to/walkthrough-operator yarn test:e2e
Clone this wiki locally