You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+176-132
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,10 @@
2
2
3
3
The Connect SDK is a TypeScript SDK for interacting with the chains Wormhole supports and the [protocols](#protocols) built on top of Wormhole.
4
4
5
+
## Warning
6
+
7
+
:warning: This package is a Work in Progress so the interface may change and there are likely bugs. Please [report](https://github.com/wormhole-foundation/connect-sdk/issues) any issues you find. :warning:
8
+
5
9
## Installation
6
10
7
11
Install the primary package
@@ -39,6 +43,8 @@ import { SolanaPlatform } from "@wormhole-foundation/connect-sdk-solana";
// util to grab an RPC client, cached after the first call
56
67
srcChain.getRpc(); // => RpcConnection<'Evm'>
57
68
```
58
69
70
+
## Concepts
71
+
72
+
Understanding several higher level concepts of the SDK will help in using it effectively.
73
+
74
+
### Platforms
75
+
76
+
Every chain is its own special snowflake but many of them share similar functionality. The `Platform` modules provide a consistent interface for interacting with the chains that share a platform.
77
+
78
+
Each platform can be installed separately so that dependencies can stay as minimal as possible.
79
+
80
+
### Chain Context
81
+
82
+
The `Wormhole` class provides a `getChain` method that returns a `ChainContext` object for a given chain. This object provides access to the chain specific methods and utilities. Much of the functionality in the `ChainContext` is provided by the `Platform` methods but the specific chain may have overridden methods.
83
+
84
+
The ChainContext object is also responsible for holding a cached rpc client and protocol clients.
85
+
86
+
```ts
87
+
// Get the chain context for the source and destination chains
88
+
// This is useful to grab direct clients for the protocols
Within the Wormhole context, addresses are often [normalized](https://docs.wormhole.com/wormhole/blockchain-environments/evm#addresses) to 32 bytes and referred to in this SDK as a `UniversalAddresses`.
100
+
101
+
Each platform comes with an address type that understands the native address formats, unsurprisingly referred to as NativeAddress. This abstraction allows the SDK to work with addresses in a consistent way regardless of the underlying chain.
102
+
103
+
```ts
104
+
// Its possible to convert a string address to its Native address
In order to sign transactions, an object that fulfils the `Signer` interface is required. This is a simple interface that can be implemented by wrapping a web wallet or other signing mechanism.
140
+
141
+
```ts
142
+
// A Signer is an interface that must be provided to certain methods
143
+
// in the SDK to sign transactions. It can be either a SignOnlySigner
144
+
// or a SignAndSendSigner depending on circumstances.
145
+
// A Signer can be implemented by wrapping an existing offline wallet
See the testing signers ([Evm](https://github.com/wormhole-foundation/connect-sdk/blob/main/platforms/evm/src/signer.ts), [Solana](https://github.com/wormhole-foundation/connect-sdk/blob/main/platforms/solana/src/signer.ts), ...) for an example of how to implement a signer for a specific chain or platform.
178
+
179
+
### Protocols
180
+
181
+
While Wormhole itself is a Generic Message Passing protocol, a number of protocols have been built on top of it to provide specific functionality.
182
+
183
+
Each Protocol, if available, will have a Platform specific implementation. These implementations provide methods to generate transactions or read state from the contract on-chain.
184
+
185
+
#### Wormhole Core
186
+
187
+
The protocol that underlies all Wormhole activity is the Core protocol. This protocol is responsible for emitting the message containing the information necessary to perform bridging including [Emitter address](https://docs.wormhole.com/wormhole/reference/glossary#emitter), the [Sequence number](https://docs.wormhole.com/wormhole/reference/glossary#sequence) for the message and the Payload of the message itself.
Within the payload is the information necessary to perform whatever action is required based on the Protocol that uses it.
208
+
209
+
#### Token Bridge
210
+
211
+
The most familiar protocol built on Wormhole is the Token Bridge.
212
+
213
+
Every chain has a `TokenBridge` protocol client that provides a consistent interface for interacting with the Token Bridge. This includes methods to generate the transactions required to transfer tokens, as well as methods to generate and redeem attestations.
214
+
215
+
Using the `WormholeTransfer` abstractions is the recommended way to interact with these protocols but it is possible to use them directly
Supported protocols are defined in the [definitions module](https://github.com/wormhole-foundation/connect-sdk/tree/main/core/definitions/src/protocols).
232
+
233
+
59
234
### Wormhole Transfer
60
235
61
236
While using the [ChainContext](#chain-context) and [Protocol](#protocols) clients directly is possible, to do things like transfer tokens, the SDK provides some helpful abstractions.
Understanding several higher level concepts of the SDK will help in using it effectively.
195
-
196
-
### Platforms
197
-
198
-
Every chain is its own special snowflake but many of them share similar functionality. The `Platform` modules provide a consistent interface for interacting with the chains that share a platform.
199
-
200
-
Each platform can be installed separately so that dependencies can stay as minimal as possible.
201
-
202
-
### Chain Context
203
-
204
-
The `Wormhole` class provides a `getChain` method that returns a `ChainContext` object for a given chain. This object provides access to the chain specific methods and utilities. Much of the functionality in the `ChainContext` is provided by the `Platform` methods but the specific chain may have overridden methods.
205
-
206
-
The ChainContext object is also responsible for holding a cached rpc client and protocol clients.
207
-
208
-
```ts
209
-
// Get the chain context for the source and destination chains
210
-
// This is useful to grab direct clients for the protocols
While Wormhole itself is a Generic Message Passing protocol, a number of protocols have been built on top of it to provide specific functionality.
222
-
223
-
#### Token Bridge
224
-
225
-
The most familiar protocol built on Wormhole is the Token Bridge.
226
-
227
-
Every chain has a `TokenBridge` protocol client that provides a consistent interface for interacting with the Token Bridge. This includes methods to generate the transactions required to transfer tokens, as well as methods to generate and redeem attestations.
228
-
229
-
Using the `WormholeTransfer` abstractions is the recommended way to interact with these protocols but it is possible to use them directly
Supported protocols are defined in the [definitions module](https://github.com/wormhole-foundation/connect-sdk/tree/main/core/definitions/src/protocols).
246
-
247
-
### Signers
248
-
249
-
In order to sign transactions, an object that fulfils the `Signer` interface is required. This is a simple interface that can be implemented by wrapping a web wallet or other signing mechanism.
250
-
251
-
```ts
252
-
// A Signer is an interface that must be provided to certain methods
253
-
// in the SDK to sign transactions. It can be either a SignOnlySigner
254
-
// or a SignAndSendSigner depending on circumstances.
255
-
// A Signer can be implemented by wrapping an existing offline wallet
See the testing signers ([Evm](https://github.com/wormhole-foundation/connect-sdk/blob/main/platforms/evm/src/testing/signer.ts), [Solana](https://github.com/wormhole-foundation/connect-sdk/blob/main/platforms/solana/src/testing/signer.ts), ...) for an example of how to implement a signer for a specific chain or platform.
288
-
289
-
```ts
290
-
// Create a signer for the source and destination chains
291
-
const sender:Signer=// ...
292
-
const receiver:Signer=// ...
293
-
294
-
```
295
-
296
-
### Addresses
297
-
298
-
Within the Wormhole context, addresses are [normalized](https://docs.wormhole.com/wormhole/blockchain-environments/evm#addresses) to 32 bytes and referred to in this SDK as a `UniversalAddresses`.
299
-
300
-
Each platform comes with an address type that understands the native address formats, unsurprisingly referred to as NativeAddress. This abstraction allows the SDK to work with addresses in a consistent way regardless of the underlying chain.
The tsdoc is available [here](https://wormhole-foundation.github.io/connect-sdk/)
323
-
324
-
## WIP
325
-
326
-
:warning: This package is a Work in Progress so the interface may change and there are likely bugs. Please [report](https://github.com/wormhole-foundation/connect-sdk/issues) any issues you find. :warning:
370
+
The tsdoc is available [here](https://wormhole-foundation.github.io/connect-sdk/)
0 commit comments