Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Commit ff84aac

Browse files
author
Carson Aberle
committed
Added more info to README
1 parent 104eb98 commit ff84aac

File tree

1 file changed

+106
-30
lines changed

1 file changed

+106
-30
lines changed

README.md

+106-30
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,136 @@
11
# @sei-js/core
2-
A library for Sei written in Typescript.
2+
This project provides helpful javascript functions for developing with [Sei](https://www.seinetwork.io) written in Typescript.
33

4-
## Installation
5-
```yarn add @sei-js/core``` or ```npm install @sei-js/core```
64

7-
## Modules
8-
| Module | Link |
9-
|--------|-----------------------|
10-
| Wallet | [learn more](#wallet) |
11-
| Client | [learn more](#client) |
5+
## Getting Started
126

13-
### Wallet**
7+
### Tutorial
8+
For an in depth ReactJS tutorial please see [our documentation.](https://app.gitbook.com/o/YiBih4jOIh8lif9Z44jw/s/vVOoEaSQGRIbgTgSvoEo/front-end-development/javascript-tutorial)
9+
10+
### Installation
11+
```shell
12+
yarn add @sei-js/core
13+
```
14+
15+
## Wallet Connection
16+
This package is officially supported by the following wallets; one of which is required for front end development.
17+
18+
* [keplr](https://www.keplr.app/download)
19+
* [leap](https://www.leapwallet.io/)
20+
* [falcon](https://www.falconwallet.app/)
21+
* [coin98](https://coin98.com/wallet)
22+
23+
### Basic wallet connection
1424
```javascript
15-
import { connect, SUPPORTED_WALLETS, getChainSuggest } from '@sei-js/core/wallet
25+
import { connect } from '@sei-js/core/wallet';
1626

17-
const { accounts, offlineSigner } = connect('leap') //optionally pass in custom chainId, rpcUrl, and restUrl
27+
const { accounts, offlineSigner } = connect('leap');
1828
```
1929

20-
| Property | Type | Description |
21-
|-------------------|---------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
22-
| connect() | (walletKey: string, chainId?: string, restUrl?: string, rpcUrl?: string) => { accounts, offlineSigner} | Async function to connect to input wallet with optional custom chainId and rpc/rest urls |
23-
| SUPPORTED_WALLETS | string[] | A list of currently supported wallets which can be passed to connect() |
24-
| getChainSuggest | (chainId?: string, restUrl?: string, rpcUrl?: string) -> object | A pre defined object to be passed to a wallets experimentalChainSuggest function. Takes optional parameters for chainId, restUrl, and rpcUrl. |
30+
### Connect to a custom node
31+
If you need to connect to a custom node, chain, or simply use a specific rest/rpc url, the ```connect()``` function contains optional inputs for these values.
32+
```javascript
33+
import { connect } from '@sei-js/core/wallet';
2534

26-
### Client
27-
#### Query Client
28-
The query client is used to query data from modules via REST endpoints.
35+
const { accounts, offlineSigner } = connect('keplr', 'atlantic-1', 'https://example-rest.com', 'https://example-rpc.com');
36+
```
37+
38+
### List of officially supported wallets
39+
```SUPPORTED_WALLETS``` contains the walletKeys which are the first input to the ```connect()``` function and are helpful to display wallet options in your UI.
40+
```javascript
41+
import { SUPPORTED_WALLETS } from '@sei-js/core/wallet';
42+
43+
console.log(SUPPORTED_WALLETS); // [{ windowKey: 'keplr' }, { windowKey: 'leap' }, { windowKey: 'falcon' }, { windowKey: 'coin98' }]
44+
```
45+
46+
## Query Client
47+
The proto query client is used to query data from modules. For a comprehensive list of all endpoints available please see our [proto package](https://github.com/sei-protocol/js-proto/tree/main/proto).
2948

3049
```javascript
3150
import { QueryClient } from '@sei-js/core';
3251

33-
const queryClient = await QueryClient.getQueryClient(rpcEndpoint);
52+
const queryClient = await QueryClient.getQueryClient('https://example-rpc.com');
3453

3554
// Getting the market summary from the Sei dex module
3655
queryClient.seiprotocol.seichain.dex.getMarketSummary(params)
3756

3857
// Getting user balances from the Cosmos bank module
39-
queryClient.cosmos.bank.v1beta1.allBalances({ address})
58+
queryClient.cosmos.bank.v1beta1.allBalances(params)
4059
```
4160

42-
#### Signing Client
61+
## Signing Client
4362
The signing client provides a way to sign and broadcast transactions on Sei.
4463

45-
Use `getSigningClient` to get your `SigningStargateClient`, with the Sei proto/amino messages loaded in.
64+
Use `getSigningClient` to get your [SigningStargateClient](https://cosmos.github.io/cosmjs/latest/stargate/classes/SigningStargateClient.html), with the Sei proto/amino messages loaded in.
4665

66+
### Token transfer
4767
```javascript
48-
import { SigningClient } from '@sei-js/core';
68+
import { SigningClient, Wallet } from '@sei-js/core';
69+
70+
const { accounts, offlineSigner } = Wallet.connect('leap');
4971

50-
const client = await SigningClient.getSigningClient({
51-
rpcEndpoint,
52-
signer // OfflineSigner
72+
const signingStargateClient = await SigningClient.getSigningClient({
73+
RPC_ENDPOINT,
74+
offlineSigner
5375
});
76+
77+
const fee = calculateFee(100000, GasPrice.fromString('1usei'));
78+
const transferAmount = { amount: SEND_AMOUNT, denom: TOKEN_DENOM };
79+
80+
const sendResponse = await signingStargateClient.sendTokens(accounts[0], DESTINATION_ADDRESSS, [transferAmount], fee);
81+
```
82+
83+
### IBC Token transfer
84+
```javascript
85+
import { SigningClient, Wallet } from '@sei-js/core';
86+
87+
const { accounts, offlineSigner } = Wallet.connect('leap');
88+
89+
const signingStargateClient = await SigningClient.getSigningClient({
90+
RPC_ENDPOINT,
91+
offlineSigner
92+
});
93+
94+
const fee = calculateFee(100000, GasPrice.fromString('1usei'));
95+
const transferAmount = { amount: SEND_AMOUNT, denom: TOKEN_DENOM };
96+
97+
const ibcResponse = await signingStargateClient.sendIbcTokens(accounts[0].address, DESTINATION_ADDRESSS, transferAmount, 'transfer', CHANNEL_ID, undefined, undefined, fee)
98+
```
99+
100+
101+
### Execute a contract (mint)
102+
```javascript
103+
import { SigningClient, Wallet } from '@sei-js/core';
104+
105+
const { accounts, offlineSigner } = Wallet.connect('leap');
106+
107+
const signingStargateClient = await SigningClient.getSigningClient({
108+
RPC_ENDPOINT,
109+
offlineSigner
110+
});
111+
112+
const account = accounts[0];
113+
const mintMsg = { mint: {} };
114+
115+
const msg = {
116+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
117+
value: {
118+
sender: account.address,
119+
contract: CONTRACT_ADDR,
120+
msg: toUtf8(JSON.stringify(mintMsg)),
121+
funds: [],
122+
}
123+
}
124+
125+
const mintResponse = await signingStargateClient.signAndBroadcast(account.address, [msg], fee);
54126
```
55127

128+
### Related packages
129+
* [@sei-js/react](https://www.npmjs.com/package/@sei-js/react) - A react helper library for common @sei-js/core functions
130+
* [@sei-js/proto](https://www.npmjs.com/package/@sei-js/proto) - TypeScript library for Sei protobufs generated using Telescope
56131

57-
## Related packages
58-
[@sei-js/react](https://www.npmjs.com/package/@sei-js/react) - A react helper library for common @sei-js/core functions
132+
### Examples
133+
* [sei-protocol/sei-examples](https://github.com/sei-protocol/js-examples) - TypeScript library for Sei protobufs generated using Telescope
59134

60-
[@sei-js/proto](https://www.npmjs.com/package/@sei-js/proto) - TypeScript library for Sei protobufs generated using Telescope
135+
### Documentation
136+
* [Sei Documentation](https://app.gitbook.com/o/YiBih4jOIh8lif9Z44jw/s/vVOoEaSQGRIbgTgSvoEo/front-end-development/javascript-tutorial) - TypeScript library for Sei protobufs generated using Telescope

0 commit comments

Comments
 (0)