Skip to content

Commit 4f2e1f0

Browse files
nambrotgitbook-bot
authored andcommittedMay 10, 2022
GitBook: [hyperlane-xyz#56] SDK v0
1 parent 71992ab commit 4f2e1f0

17 files changed

+202
-48
lines changed
 

‎SUMMARY.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@
2424

2525
## Developers
2626

27-
* [Getting started](developers/getting-started/README.md)
28-
* [Write your contracts](developers/getting-started/write-your-contracts.md)
29-
* [Test your contracts](developers/getting-started/test-your-contracts.md)
30-
* [Deploy your app](developers/getting-started/deploy-your-app.md)
31-
* [Build your SDK](developers/getting-started/build-your-sdk.md)
32-
* [Environments](developers/environments.md)
27+
* [Getting started](developers/getting-started.md)
28+
* [Contracts SDK](developers/contracts-sdk/README.md)
29+
* [Write your contracts](developers/contracts-sdk/write-your-contracts.md)
30+
* [Test your contracts](developers/contracts-sdk/test-your-contracts.md)
31+
* [Application SDK](developers/application-sdk/README.md)
32+
* [Deployment Tooling](developers/application-sdk/deployment-tooling.md)
33+
* [Environments](developers/environments/README.md)
34+
* [Interaction API](developers/environments/interaction-api.md)
35+
* [MultiProvider](developers/environments/multiprovider.md)
3336
* [Advanced](developers/advanced/README.md)
34-
* [AbacusConnectionClient.sol](developers/advanced/abacusconnectionclient.sol.md)
35-
* [Router.sol](developers/advanced/router.sol.md)
37+
* [Connection Client](developers/advanced/connection-client.md)
38+
* [Router Pattern](developers/advanced/router-pattern.md)
3639
* [Message encoding](developers/advanced/message-encoding.md)
3740
* [Gas](developers/advanced/gas.md)
3841
* [Examples](developers/examples/README.md)

‎contract-addresses/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Contract Addresses
22

3-
This section contains the contract Addresses of the Abacus core platform. We recommend developers to use Abacus' SDKs which bundle these addresses via [Environments](../developers/environments.md).
3+
This section contains the contract Addresses of the Abacus core platform. We recommend developers to use Abacus' SDKs which bundle these addresses via [Environments](../developers/environments/).

‎developers/advanced/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ description: Digging deeper into interchain application development
66

77
Now that you've gotten the feel for building a simple interchain application, it's time to start exploring some more advanced concepts.
88

9-
This section covers some library contracts that you might find helpful, the [Router pattern](router.sol.md) for building interchain apps, different approaches to [message encoding](message-encoding.md) and decoding, and more.
9+
This section covers some library contracts that you might find helpful, the [Router pattern](router-pattern.md) for building interchain apps, different approaches to [message encoding](message-encoding.md) and decoding, and more.

‎developers/advanced/abacusconnectionclient.sol.md ‎developers/advanced/connection-client.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
description: The easiest way to connect your application to Abacus
33
---
44

5-
# AbacusConnectionClient.sol
5+
# Connection Client
66

77
To send and receive interchain messages, your application will need to be aware of the Abacus contract addresses. Inheriting from [`AbacusConnectionClient`](https://github.com/abacus-network/abacus-monorepo/blob/main/solidity/app/contracts/AbacusConnectionClient.sol) is the easiest way to manage these pointers.
88

9-
## AbacusConnectionManager
9+
## Abacus Connection Manager
1010

1111
Before diving into `AbacusConnectionClient`, first let's zoom out, and take a look at [`AbacusConnectionManager`](https://github.com/abacus-network/abacus-monorepo/blob/main/solidity/core/contracts/AbacusConnectionManager.sol), an out-of-the-box solution for managing Abacus contract addresses.
1212

@@ -22,7 +22,7 @@ Over time, we expect a number of incremental improvements to the Abacus protocol
2222

2323
Using an `AbacusConnectionManager` allows applications to migrate to a new Abacus deployment with just a few transactions.
2424

25-
## AbacusConnectionClient
25+
## Abacus Connection Client
2626

2727
``[`AbacusConnectionClient`](https://github.com/abacus-network/abacus-monorepo/blob/main/solidity/app/contracts/AbacusConnectionClient.sol) is a simple mix-in contract that application developers can inherit from in order to connect to Abacus.
2828

‎developers/advanced/gas.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ The contract has a single payable function, which takes a message leaf index (wh
3030
function payGasFor(uint256 _leafIndex) external payable;
3131
```
3232

33-
Developers can specify the address of the `InterchainGasPaymaster` that they're using via their [`AbacusConnectionManager`](abacusconnectionclient.sol.md#abacusconnectionmanager). For convenience, Abacus Works will operate a processor and relayer, and deploy corresponding `AbacusConnectionManager` and `InterchainGasPaymasters` that application developers can point to if they choose.
33+
Developers can specify the address of the `InterchainGasPaymaster` that they're using via their [`AbacusConnectionManager`](connection-client.md#abacusconnectionmanager). For convenience, Abacus Works will operate a processor and relayer, and deploy corresponding `AbacusConnectionManager` and `InterchainGasPaymasters` that application developers can point to if they choose.
3434

3535
## Checkpoints
3636

37-
Because an application will often want to checkpoint and/or pay for gas while dispatching a message, convenience functions are provided in [Router.sol](router.sol.md). The following table shows each of these convenience functions and what they do.
37+
Because an application will often want to checkpoint and/or pay for gas while dispatching a message, convenience functions are provided in [Router.sol](router-pattern.md). The following table shows each of these convenience functions and what they do.
3838

3939
| Function | Interchain gas payment? | Creates a checkpoint? |
4040
| ------------------------------- | ----------------------- | --------------------- |
@@ -53,9 +53,9 @@ Applications can use the `InterchainGasCalculator` in the Abacus SDK to estimate
5353

5454
### Smart Contract
5555

56-
Adapting the simple example from the [Getting started](../getting-started/write-your-contracts.md) section, let's have our `HelloWorld` application dispatch a message, pay interchain gas for that message, and create a checkpoint. Note the `HelloWorld` contract now inherits from [Router.sol](router.sol.md).
56+
Adapting the simple example from the [Getting started](../contracts-sdk/write-your-contracts.md) section, let's have our `HelloWorld` application dispatch a message, pay interchain gas for that message, and create a checkpoint. Note the `HelloWorld` contract now inherits from [Router.sol](router-pattern.md).
5757

58-
We will use the internal function `_dispatchWithGasAndCheckpoint`, which is implemented in [`Router.sol`](router.sol.md). It will first dispatch a message to a remote router, then pay a specified amount of origin chain native tokens to the `InterchainGasPaymaster` contract that's been set in the `AbacusConnectionManager`, and then create a checkpoint on the `Outbox`. No special handling logic, apart from simply implementing the `handle()` function, is required.
58+
We will use the internal function `_dispatchWithGasAndCheckpoint`, which is implemented in [`Router.sol`](router-pattern.md). It will first dispatch a message to a remote router, then pay a specified amount of origin chain native tokens to the `InterchainGasPaymaster` contract that's been set in the `AbacusConnectionManager`, and then create a checkpoint on the `Outbox`. No special handling logic, apart from simply implementing the `handle()` function, is required.
5959

6060
```solidity
6161
import {Router} from "@abacus-network/app/contracts/Router.sol";

‎developers/advanced/router.sol.md ‎developers/advanced/router-pattern.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
description: A pattern for building interchain applications
33
---
44

5-
# Routers
5+
# Router Pattern
66

7-
While patterns and best practices will evolve over time, the `Router` pattern has emerged as an early model for building interchain applications.
7+
While patterns and best practices will evolve over time, the Router pattern has emerged as a useful model for building interchain applications.
88

9-
Developers can build applications following this pattern by inheriting from the `Router` mix-in contract, and implementing functions that send and receive messages to and from remote chains.
9+
The Router pattern allows developers to write application logic once while deploying it to many networks. Developers can leverage this pattern by inheriting from the [`Router.sol` mix-in contract](https://github.com/abacus-network/abacus-monorepo/blob/main/solidity/app/contracts/Router.sol), and implementing functions that send and receive messages to and from remote chains.
1010

1111
Developers then deploy their contracts on each chain that they would like their application to support. Each contract must be made aware of their counterparts on all remote chains so that they can authenticate the messages that they send between each other.
1212

‎developers/application-sdk/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
description: Manage multi-chain applications using the Abacus SDK
3+
---
4+
5+
# Application SDK
6+
7+
The Abacus Application SDK help developers manage multichain Abacus applications. This requires a higher level API than dApp developers are familiar with which is namespaced by target network. It is composed of 2 main packages: tooling for multichain deployments and an interaction API.
8+
9+
### [Deployment Tooling](deployment-tooling.md)
10+
11+
The `@abacus-network/deploy` package facilitates configuration and deployment of Abacus applications. This includes utilities for bytecode verification, working with various proxy contracts patterns, and sanity checking deployments for consistency across chains.
12+
13+
### [Interaction API](../environments/interaction-api.md)
14+
15+
The `AbacusApp` abstraction exported in the `@abacus-network/sdk` package manages collections of contract interfaces on each network. This can be extended and instantiated with artifacts generated by the deployment tooling.
16+
17+
#### [MultiProvider](../environments/multiprovider.md)
18+
19+
The `MultiProvider` exported in the `@abacus-network/sdk` package abstracts away node interaction for supported Abacus networks. This includes utilities for transaction signing and estimating the gas costs of processing dispatched messages to remote chains. 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
description: Deploy your application on multiple chains
3+
---
4+
5+
# Deployment Tooling
6+
7+
The Abacus deployment tooling simplifies the deployment of Abacus smart contract applications to configured target networks.
8+
9+
### Install
10+
11+
```shell
12+
yarn add @abacus-network/deploy
13+
```
14+
15+
### Implement
16+
17+
To leverage the `AbacusAppDeployer` abstraction, developers must provide an implementation for `deployContracts` which describes the logic for deploying the application on a single network. 
18+
19+
```typescript
20+
import { AbacusAppDeployer } from '@abacus-network/deploy';
21+
import { ChainName } from '@abacus-network/sdk';
22+
23+
class MyDeployer<Networks extends ChainName, MyConfig>
24+
extends AbacusAppDeployer<Networks, MyConfig> {
25+
function deployContracts(network: Networks, config: MyConfig) {
26+
// deploy contracts here
27+
}
28+
}
29+
```
30+
31+
There are `deployContract` and `deployProxiedContract` helper functions included in `AbacusAppDeployer` which can simplify the `deployContracts` implementation.&#x20;
32+
33+
```typescript
34+
this.deployContract(network, 'MyContract', MyContract__factory, config.args);
35+
```
36+
37+
{% hint style="info" %}
38+
Please see the [Examples section](../examples/) for an implementation of the `AbacusAppDeployer` abstraction`.`
39+
{% endhint %}
40+
41+
### Deploy
42+
43+
Once a single network's implementation is specified, a deployer can be instantiated with a [multiprovider.md](../environments/multiprovider.md "mention") and corresponding config. The subsequent `deploy()` invocation will perform deployment for all networks specified in the configuration.
44+
45+
```typescript
46+
const ethereum: MyConfig = {...};
47+
const polygon: MyConfig = {...};
48+
const myDeployer = new MyDeployer(multiProvider, { ethereum, polygon });
49+
const addresses = await myDeployer.deploy();
50+
```
51+
52+
{% hint style="info" %}
53+
Persisting deployment artifacts will be very important for future use of your application. This goes beyond just addresses and includes compiler options and constructor arguments.
54+
{% endhint %}
55+
56+
There is a `writeOutput` helper function included in `AbacusAppDeployer` that will assist in writing these artifacts to disk.&#x20;
57+
58+
```typescript
59+
deployer.writeOutput('./output', addresses)
60+
```

‎developers/contracts-sdk/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contracts SDK
2+
3+
Smart contract applications built on top of Abacus must only be written once but are typically deployed and operational across many chains.

‎developers/getting-started/test-your-contracts.md ‎developers/contracts-sdk/test-your-contracts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ In the future, Abacus will support additional testing frameworks, including [Fou
1212

1313
First, install the plugin:
1414

15-
```
15+
```shell
1616
yarn add --dev @abacus-network/hardhat
1717
```
1818

‎developers/getting-started/write-your-contracts.md ‎developers/contracts-sdk/write-your-contracts.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The first step in building an interchain application is writing your smart contr
1010

1111
Developers can send messages to other chains by calling the `dispatch()` function on the [`Outbox`](../../protocol/messaging/outbox.md) smart contract.
1212

13-
Note that we inherit from [`AbacusConnectionClient`](../advanced/abacusconnectionclient.sol.md), a simple contract that helps us keep track of the Abacus [`Inbox`](../../protocol/messaging/inbox.md) and [`Outbox`](../../protocol/messaging/outbox.md) contracts on our local chain.
13+
Note that we inherit from [`AbacusConnectionClient`](../advanced/connection-client.md), a simple contract that helps us keep track of the Abacus [`Inbox`](../../protocol/messaging/inbox.md) and [`Outbox`](../../protocol/messaging/outbox.md) contracts on our local chain.
1414

1515
```solidity
1616
import {AbacusConnectionClient} from "@abacus-network/app/contracts/AbacusConnectionClient.sol";
@@ -63,9 +63,9 @@ contract HelloWorld is AbacusConnectionClient {
6363

6464
## Try it yourself!
6565

66-
To get started writing your contracts, simply install [@abacus-network/app](https://www.npmjs.com/package/@abacus-network/app) and inherit from [`AbacusConnectionClient`](../advanced/abacusconnectionclient.sol.md).
66+
To get started writing your contracts, simply install [@abacus-network/app](https://www.npmjs.com/package/@abacus-network/app) and inherit from [`AbacusConnectionClient`](../advanced/connection-client.md).
6767

6868
You can also use the [template repo](https://github.com/abacus-network/abacus-app-template), which has everything you need to write, test, deploy, and interact with, your first interchain application.
6969

70-
Looking to build something a bit more complex? Consider taking a look at the [Router pattern](../advanced/router.sol.md) for interchain applications.
70+
Looking to build something a bit more complex? Consider taking a look at the [Router pattern](../advanced/router-pattern.md) for interchain applications.
7171

File renamed without changes.
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
description: Interact with your application on multiple chains
3+
---
4+
5+
# Interaction API
6+
7+
The Abacus Interaction API simplifies the interface for smart contract applications deployed across multiple networks. It provides a Typescript interface for invoking an application's smart contract methods on a target network, leveraging the [`MultiProvider`](multiprovider.md) for node API interaction.&#x20;
8+
9+
### Install
10+
11+
```shell
12+
yarn add @abacus-network/sdk
13+
```
14+
15+
### Implement
16+
17+
The `AbacusApp` abstraction is a mapping that resolves a network namespace to a collection of [ethers Contract](https://docs.ethers.io/v5/api/contract/contract/#Contract) instances on that network. A default implementation of this collection called [`AbacusContracts`](https://github.com/abacus-network/abacus-monorepo/blob/main/typescript/sdk/src/contracts.ts#L37) is provided which should satisfy most conceivable designs. This implementation ensures your contracts collections are attached to the appropriate network providers.
18+
19+
{% hint style="info" %}
20+
Please see the [Examples section](../examples/) for a demonstration of how to leverage the `AbacusApp` abstraction`.`
21+
{% endhint %}
22+
23+
### Interact
24+
25+
Once an `AbacusApp` implementation is defined, it can be instantiated using the output generated from the [`AbacusAppDeployer`](../application-sdk/deployment-tooling.md) and an instance of the [`MultiProvider`](multiprovider.md).&#x20;
26+
27+
```typescript
28+
import { addresses } from './deployOutput';
29+
const myApp = new MyApp(addresses, multiProvider);
30+
```
31+
32+
{% hint style="warning" %}
33+
It is currently not possible to provide a set of networks in the `MultiProvider` which is only a subset of networks in the `addresses` constructor argument. This behavior is being fixed in a future release.
34+
{% endhint %}
35+
36+
To interact with contracts on a particular network, simply provide the namespace to the app.&#x20;
37+
38+
```typescript
39+
const ethereumContracts = myApp.getContracts('ethereum');
40+
```
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
description: Manage node providers for Abacus supported networks in one plac
3+
---
4+
5+
# MultiProvider
6+
7+
&#x20;`MultiProvider` is a network utility used throughout the Abacus Application SDK. In essence, it is a mapping that resolves a network namespace to a configured node provider.
8+
9+
### Configuration
10+
11+
It has a simple interface for configuring target networks that are supported by the Abacus core protocol.
12+
13+
```typescript
14+
const ethereum = {
15+
provider: new UrlJsonRpcProvider('http://localhost:8545/')
16+
}
17+
const polygon = {
18+
provider: new UrlJsonRpcProvider('https://rpc-mainnet.matic.network'),
19+
confirmations: 10, // wait 10 blocks for finality
20+
}
21+
const multiProvider = new MultiProvider({ ethereum, polygon });
22+
```
23+
24+
### Use
25+
26+
`MultiProvider` allows, for example, an application to have static node provisioning per target network and register a user's signer for the duration of a session.
27+
28+
```typescript
29+
const userSigner = await getSessionSigner();
30+
serverMultiProvider.getDomainConnection('ethereum').registerSigner(userSigner);
31+
```
32+
33+
### Testing
34+
35+
For use in hardhat tests, we can provide the hardhat `signer` to multiple test networks to emulate a multichain system locally. The networks shown (`test1`, `test2`, `test3`) are included for convenience.
36+
37+
```typescript
38+
import { ethers } from 'hardhat';
39+
40+
const [signer] = await ethers.getSigners();
41+
const testMultiProvider = new MultiProvider({
42+
test1: { signer },
43+
test2: { signer }
44+
test3: { signer }
45+
});
46+
```
47+

‎developers/getting-started/README.md ‎developers/getting-started.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ _**Looking for a tutorial?**_** ** Keep reading for a step-by-step walkthrough o
1010

1111
_**Ready to dive in?**_ Use the [template repo](https://github.com/abacus-network/abacus-app-template) to quickly get started with everything you need&#x20;
1212

13-
_**Not sure what to build?**_ Take a look at some [example applications](../examples/) to see what you can do
13+
_**Not sure what to build?**_ Take a look at some [example applications](examples/) to see what you can do
1414

1515
_**Have questions?**_ We'd love to answer them! Ask us on [discord](https://discord.com/invite/KBD3aD78Bb), reach out on [twitter](https://twitter.com/Abacus\_Network), or ping us on Telegram
1616

1717
## Building with Abacus
1818

1919
Abacus aims to be the simplest platform for building interchain applications, i.e. applications that send and receive messages to and from multiple blockchains.
2020

21-
Abacus provides a simple API for interchain communication that application developers can integrate. In the end, building an interchain application is as simple as writing a smart contract that sends messages to an Abacus [`Outbox`](../../protocol/messaging/outbox.md) and receives messages from an Abacus [`Inbox`](../../protocol/messaging/inbox.md).
21+
Abacus provides a simple API for interchain communication that application developers can integrate. In the end, building an interchain application is as simple as writing a smart contract that sends messages to an Abacus [`Outbox`](../protocol/messaging/outbox.md) and receives messages from an Abacus [`Inbox`](../protocol/messaging/inbox.md).
2222

2323
In addition to this API, Abacus provides a suite of developer tools, including:
2424

2525
* A [template repo](https://github.com/abacus-network/abacus-app-template) with everything you need to get started
26-
* A [mix-in smart contract](../advanced/abacusconnectionclient.sol.md) that your application can inherit from
26+
* A [mix-in smart contract](advanced/connection-client.md) that your application can inherit from
2727
* A [hardhat plugin](https://www.npmjs.com/package/@abacus-network/hardhat) for unit testing interchain applications
28-
* [An SDK](build-your-sdk.md) for interacting with multiple blockchains
29-
* Multi-chain [deployment tooling](deploy-your-app.md)
30-
* A number of [example applications](../examples/)
28+
* Multi-chain [deployment tooling](application-sdk/deployment-tooling.md)
29+
* An [SDK for interacting](environments/interaction-api.md) with multiple blockchains
30+
* A number of [example applications](examples/)

‎developers/getting-started/build-your-sdk.md

-7
This file was deleted.

‎developers/getting-started/deploy-your-app.md

-11
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.