-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from linnnsss/update_SDK_examples
Update sdk examples (in rust, go, java, JS)
- Loading branch information
Showing
7 changed files
with
297 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
id: sdk_examples_go | ||
title: Go | ||
sidebar_position: 3 | ||
--- | ||
|
||
import useBaseUrl from "@docusaurus/useBaseUrl"; | ||
|
||
import Link from "@docusaurus/Link"; | ||
|
||
## Single-sig transfer | ||
|
||
- With [Secp256k1](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L21-L60) | ||
- With [Omnilock](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L408-L460) | ||
- With [Light-client](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L62) | ||
|
||
## Multi-sig transfer | ||
|
||
- With [Secp256k1](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L114) | ||
- With [Omnilock](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L462) | ||
|
||
## Chained transfer | ||
|
||
- [Chained transfer](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L529) | ||
|
||
## Issue and send SUDT | ||
|
||
- [Issue](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L176) | ||
|
||
- [Send](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L220) | ||
|
||
## DAO Deposit | ||
|
||
- [Deposit](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L264) | ||
|
||
## DAO Withdrawal | ||
|
||
- [Withdraw](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L304) | ||
- [Claim](https://github.com/nervosnetwork/ckb-sdk-go/blob/4f43fd577e215b746e2c55b65fa7df2085e58c83/collector/example/example.go#L357) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
id: sdk_examples_java | ||
title: Java | ||
sidebar_position: 4 | ||
--- | ||
|
||
import useBaseUrl from "@docusaurus/useBaseUrl"; | ||
|
||
import Link from "@docusaurus/Link"; | ||
|
||
## Single-sig transfer | ||
|
||
- With [Secp256k1](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/SendCkbExample.java) | ||
- With [Omnilock](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/OmnilockExample.java) | ||
- With [Light-client](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/SendCkbByLightClientExample.java) | ||
|
||
## Multi-sig transfer | ||
|
||
- With [Secp256k1](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/SendCkbMultisigExample.java) | ||
- With [Omnilock](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/OmnilockMultisigExample.java) | ||
|
||
## Chained transfer | ||
|
||
- [Chained transfer](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/SendChainedTransactionExample.java) | ||
|
||
## Issue and send SUDT | ||
|
||
- [Issue](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/IssueSudtExample.java) | ||
|
||
- [Send](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/SendSudtExample.java) | ||
|
||
## DAO Deposit | ||
|
||
- [Deposit](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/DaoDepositExample.java) | ||
|
||
## DAO Withdrawal | ||
|
||
- [Withdraw](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/DaoWithdrawExample.java) | ||
- [Claim](https://github.com/nervosnetwork/ckb-sdk-java/blob/master/example/src/main/java/org/nervos/ckb/example/DaoClaimExample.java) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
id: sdk_examples_lumos | ||
title: Lumos/Javascript | ||
sidebar_position: 5 | ||
--- | ||
Lumos is a full-featured JavaScript/TypeScript based dapp framework. [This tutorial](https://github.com/homura/hello-lumos/tree/develop/tutorial) covers a range of actions from initializing your environment to more advanced tasks like issuing and transferring SUDT. | ||
|
||
## Single-sig transfer | ||
|
||
- With [secp256k1](https://github.com/homura/hello-lumos/blob/ee3b9c10b425caca0787e20774274c28dbfe2256/tutorial/04-transfer-alice-ckb-to-bob.ts). | ||
|
||
## Issue and send SUDT | ||
|
||
- [Issue](https://github.com/homura/hello-lumos/blob/develop/tutorial/05-issue-sudt-from-alice.ts) | ||
- [Send](https://github.com/homura/hello-lumos/blob/develop/tutorial/06-transfer-sudt-from-alice-to-bob.ts) | ||
|
||
## DAO operations | ||
|
||
You can find the code examples related to the Nervos DAO, covering the three primary operations of [depositing](https://github.com/homura/hello-lumos/blob/ee3b9c10b425caca0787e20774274c28dbfe2256/dao-tutorial/01-dao.ts#L47-L70), [withdrawing](https://github.com/homura/hello-lumos/blob/ee3b9c10b425caca0787e20774274c28dbfe2256/dao-tutorial/01-dao.ts#L72-L96), and [unlocking assets](https://github.com/homura/hello-lumos/blob/ee3b9c10b425caca0787e20774274c28dbfe2256/dao-tutorial/01-dao.ts#L98-L130) on CKB testnet by following [this](https://github.com/homura/hello-lumos/blob/develop/dao-tutorial/01-dao.ts) GitHub link. | ||
|
||
For a local development environment, you can refer to [this](https://github.com/homura/hello-lumos/blob/ee3b9c10b425caca0787e20774274c28dbfe2256/dao-tutorial/02-local-dao.ts) link instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
id: sdk_examples_overview | ||
title: Overview | ||
sidebar_position: 1 | ||
--- | ||
|
||
import useBaseUrl from "@docusaurus/useBaseUrl"; | ||
|
||
import Link from "@docusaurus/Link"; | ||
|
||
The current SDK examples, available for Rust, Go, Java, and JavaScript, provide the three most common scenarios for managing your assets: | ||
|
||
## Native CKB Transfers | ||
1. Single-sig transfer with secp256k1 and Omnilock | ||
|
||
Sign and send CKB from a single-sig address. | ||
|
||
2. Single-sig transfer using [`ckb-light-client`](https://github.com/nervosnetwork/ckb-light-client) with secp256k1 | ||
|
||
Transfer from a single-sig addresses with enhanced efficiency. | ||
|
||
3. Multi-sig transfer with secp256k1 and Omnilock | ||
|
||
Sign and send CKB with multiple private keys. | ||
|
||
4. Chained transfer with secp256k1 | ||
|
||
By using the previous transaction's output as the next one's input, chain transfer allows the construction of new transactions with unconfirmed on-chain inputs, reducing waiting time and enhancing efficiency. | ||
|
||
## SUDT Transfers | ||
SUDT (Simple User Defined Tokens) is a token standard on CKB that enables the creation and transfer of custom tokens. For more information, see [RFC 0025 Simple UDT](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0025-simple-udt/0025-simple-udt.md). | ||
|
||
1. SUDT issuance | ||
2. SUDT transfer | ||
|
||
## Nervos DAO-Related Operations | ||
Nervos DAO is a CKB smart contract that provides secondary rewards for CKByte deposits, to safeguard holders from dilution. Deposits in NervosDAO are subject to a minimum lockup period, and withdrawals are only possible once the lockup period elapses. For more information, see [RFC 0023 Deposit and Withdraw in Nervos DAO](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md). | ||
1. Deposit | ||
|
||
Deposit CKB into Nervos DAO. | ||
|
||
2. Withdrawal-1 withdraw | ||
|
||
Transform a deposit cell into a withdrawl cell. | ||
|
||
3. Withdrawal-2 claim | ||
|
||
Claim the transformed cell after a mandatory lockup period following the deposit transaction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
id: sdk_examples_rust | ||
title: Rust | ||
sidebar_position: 2 | ||
--- | ||
|
||
import useBaseUrl from "@docusaurus/useBaseUrl"; | ||
|
||
import Link from "@docusaurus/Link"; | ||
|
||
## Single-sig transfer | ||
|
||
* With [Secp256k1](https://github.com/nervosnetwork/ckb-sdk-rust/blob/master/examples/send_ckb_example.rs) | ||
|
||
* With [Omnilock](https://github.com/nervosnetwork/ckb-sdk-rust/blob/master/examples/transfer_from_omnilock.rs) | ||
|
||
|
||
## Multi-sig transfer | ||
|
||
* [1-of-2 multisig](https://github.com/nervosnetwork/ckb-sdk-rust/blob/master/examples/send_ckb_multisig_example.rs) with Secp256k1 (one of two private keys required) | ||
|
||
* [2-of-2 multisig](https://github.com/nervosnetwork/ckb-sdk-rust/blob/master/examples/transfer_from_multisig.rs | ||
) with Secp256k1 (both private keys required) | ||
|
||
* With [Omnilock](https://github.com/nervosnetwork/ckb-sdk-rust/blob/master/examples/transfer_from_omnilock_multisig.rs) | ||
|
||
## Chained transfer | ||
|
||
* [Chained transfer](https://github.com/nervosnetwork/ckb-sdk-rust/blob/master/examples/chain_transfer_sighash.rs) | ||
|
||
## Issue and send SUDT | ||
|
||
* [Issue](https://github.com/nervosnetwork/ckb-sdk-rust/blob/master/examples/sudt_issue.rs) | ||
|
||
* [Send](https://github.com/nervosnetwork/ckb-sdk-rust/blob/master/examples/sudt_send.rs) | ||
|
||
## DAO Deposit | ||
|
||
* [Deposit](https://github.com/nervosnetwork/ckb-sdk-rust/pull/70/commits/25a470f7219a6ed0fab55e055a145559813c1628) | ||
|
||
### DAO Withdrawal | ||
|
||
* [Withdraw](https://github.com/nervosnetwork/ckb-sdk-rust/pull/70/commits/4c24fca4cae40fc57d2258449b69f2fd189ed623#diff-edd624119e43a07b0e85b9517a1d3544ebe002215b31ec91700d603843bb434e) | ||
|
||
* [Claim](https://github.com/nervosnetwork/ckb-sdk-rust/pull/70/commits/dae479a751fd2c3a4991da11abd5c2076e45b735#diff-d461964487b262c57f8bdf4a2845d3e6c4dc449c2573165f1f03618e173f63c1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.