diff --git a/doc-site/docs/api/_category_.json b/doc-site/docs/api/_category_.json
index e738d78f..549674e8 100644
--- a/doc-site/docs/api/_category_.json
+++ b/doc-site/docs/api/_category_.json
@@ -1,14 +1,14 @@
{
- "position": 2,
+ "position": 3,
"label": "API",
"collapsible": true,
"collapsed": true,
"className": "red",
"link": {
"type": "generated-index",
- "title": "API"
+ "title": "apis"
},
"customProps": {
"description": ""
}
-}
+}
\ No newline at end of file
diff --git a/doc-site/docs/api/account.md b/doc-site/docs/api/account.md
deleted file mode 100644
index 6185a53c..00000000
--- a/doc-site/docs/api/account.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Account
diff --git a/doc-site/docs/api/account.mdx b/doc-site/docs/api/account.mdx
new file mode 100644
index 00000000..89307fb5
--- /dev/null
+++ b/doc-site/docs/api/account.mdx
@@ -0,0 +1,114 @@
+---
+id: account
+title: 'Account'
+---
+
+import Tx from '../../src/components/snippers/tx.mdx';
+import ApiTypes from '../../src/components/snippers/api-types.tsx';
+
+## getAccount
+
+Retrieve on-chain account information for a given address.
+
+| params | description |
+| ------- | -------------------------------- |
+| address | The given address for retrieving |
+
+```jsx title="example"
+await client.getAccount('0x0000000000000000000000000000000000000001');
+```
+
+## getAccountBalance
+
+Get the bank balance for the given address.
+
+| params | description |
+| ------- | ------------------------------------ |
+| address | the address to query balances for |
+| denom | the coin denom to query balances for |
+
+```jsx title="example"
+await client.getAccountBalance({
+ address: '0x0000000000000000000000000000000000000001',
+ denom: 'BNB',
+});
+```
+
+## getModuleAccounts
+
+Get all module accounts.
+
+```jsx title="example"
+await client.getModuleAccounts();
+```
+
+## getModuleAccountByName
+
+Get module account by module name.
+
+| params | description |
+| ------ | --------------------------------- |
+| name | the address to query balances for |
+
+```jsx title="example"
+await client.getModuleAccountByName('module_name');
+```
+
+## getPaymentAccountsByOwner
+
+Get all payment accounts owned by the given owner address.
+
+| params | description |
+| ------- | ---------------------------------------------- |
+| address | The given owner account address for retrieving |
+
+```jsx title="example"
+await client.getPaymentAccountsByOwner('0x0000000000000000000000000000000000000001');
+```
+
+## createPaymentAccount
+
+
+
+Create a new payment account for the given address.
+
+The payment account is used to pay for the storage and read quota fee of objects. When you need to
+pay for different buckets separately, you can create different payment accounts to do so. Note that
+the payment account does not have a private key, and only the owner of the payment account can
+withdraw funds from it. Once the owner revokes permission for withdrawal, the funds in the payment
+account can only be utilized to cover storage and read quota fees.
+
+| params | description |
+| ------- | -------------------------------------------- |
+| creator | The owner address of the new payment account |
+
+```jsx title="example"
+const tx = await client.account.createPaymentAccount({
+ creator: address,
+});
+```
+
+## transfer
+
+
+
+Transfer BNB from sender to receiver.
+
+| params | description |
+| ----------- | ------------------------------------ |
+| fromAddress | The address who will send the BNB |
+| toAddress | The address who will receive the BNB |
+| amount | transfer coin |
+
+```jsx title="example"
+const tx = await client.account.transfer({
+ fromAddress: '0x0000000000000000000000000000000000000000',
+ toAddress: '0x0000000000000000000000000000000000000001',
+ amount: [
+ {
+ denom: 'BNB',
+ amount: '1000000000',
+ },
+ ],
+});
+```
diff --git a/doc-site/docs/api/bucket.md b/doc-site/docs/api/bucket.md
deleted file mode 100644
index 147a2e92..00000000
--- a/doc-site/docs/api/bucket.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Bucket
diff --git a/doc-site/docs/api/bucket.mdx b/doc-site/docs/api/bucket.mdx
new file mode 100644
index 00000000..d4fbb91f
--- /dev/null
+++ b/doc-site/docs/api/bucket.mdx
@@ -0,0 +1,290 @@
+---
+id: bucket
+title: 'Bucket'
+---
+
+import ApiTypes from '../../src/components/snippers/api-types.tsx';
+import Tx from '../../src/components/snippers/tx.mdx';
+
+## createBucket
+
+Create a new bucket in greenfield. This API sends a request to the storage provider to get approval
+for creating bucket and sends the createBucket transaction to the Greenfield.
+
+| params | description |
+| ---------------- | ------------------------------------------------------- |
+| bucketName | bucket name |
+| creator | creator account address |
+| visibility | [VisibilityType](/types/visibility) |
+| chargedReadQuota | defines the traffic quota that you read from primary sp |
+| spInfo | primary sp address |
+| paymentAddress | payment address |
+| authType | [AuthType](/client/sp-client#authtype) |
+
+```jsx title="example"
+const tx = await client.bucket.createBucket(
+ {
+ bucketName: 'bucket_name',
+ creator: address,
+ visibility: 'VISIBILITY_TYPE_PUBLIC_READ',
+ chargedReadQuota: '0',
+ spInfo: {
+ primarySpAddress: 'primary_sp_address',
+ },
+ paymentAddress: address,
+ },
+ {
+ type: 'EDDSA',
+ domain: window.location.origin,
+ seed: offChainData.seedString,
+ address,
+ },
+);
+```
+
+## deleteBucket
+
+Send DeleteBucket msg to greenfield chain and return txn hash.
+
+| params | description |
+| ---------- | ------------------------------------ |
+| bucketName | The name of the bucket to be deleted |
+| operator | operator account address |
+
+```jsx title="example"
+const tx = await client.bucket.deleteBucket({
+ bucketName: bucketName,
+ operator: address,
+});
+```
+
+
+
+## deleteBucketPolicy
+
+Delete the bucket policy of the principal.
+
+| params | description |
+| ------------- | ---------------------------------------------------------------------- |
+| operator | |
+| bucketName | The bucket name identifies the bucket |
+| principalAddr | Principal define the roles that can grant permissions |
+| principalType | PrincipalType refers to the identity type of system users or entities. |
+
+```jsx title="example"
+const tx = await client.bucket.deleteBucketPolicy(
+ address,
+ bucketName,
+ address,
+ 'PRINCIPAL_TYPE_GNFD_ACCOUNT',
+);
+```
+
+
+
+## getBucketMeta
+
+This API is used to get bucket meta by bucket name.
+
+| params | description |
+| ---------- | ----------- |
+| bucketName | bucket name |
+
+```jsx title="example"
+const bucketInfo = await client.bucket.getBucketMeta({
+ bucketName,
+});
+```
+
+## getBucketPolicy
+
+Get the bucket policy info of the user specified by principalAddr.
+
+```jsx title="example"
+import { GRNToString, newBucketGRN } from '@bnb-chain/greenfield-js-sdk';
+await client.bucket.getBucketPolicy({
+ resource: GRNToString(newBucketGRN(bucketName)),
+ principalAddress: '0x00..',
+});
+```
+
+## getBucketReadQuota
+
+Query the quota info of the specific bucket of current month.
+
+| params | description |
+| ---------- | -------------------------------------- |
+| bucketName | bucket name |
+| authType | [AuthType](/client/sp-client#authtype) |
+
+```jsx title="example"
+await client.bucket.getBucketReadQuota(
+ {
+ bucketName,
+ },
+ {
+ type: 'EDDSA',
+ seed: offChainData.seedString,
+ domain: window.location.origin,
+ address,
+ },
+);
+```
+
+## headBucket
+
+query the bucketInfo on chain, return the bucket info if exists.
+
+| params | description |
+| ---------- | ----------- |
+| bucketName | bucket name |
+
+```jsx title="example"
+const bucketInfo = await client.bucket.headBucket(bucketName);
+```
+
+## headBucketById
+
+| params | description |
+| -------- | ----------- |
+| bucketId | bucket id |
+
+```jsx title="example"
+const bucketInfo = await client.bucket.headBucketById(bucketId);
+```
+
+## headBucketExtra
+
+Queries a bucket extra info (with gvg bindings and price time) with specify name.
+
+| params | description |
+| ---------- | ----------- |
+| bucketName | bucket name |
+
+```jsx title="example"
+const bucketInfo = await client.bucket.headBucketExtra(bucketName);
+```
+
+
+
+## listBucketReadRecords
+
+List the download record info of the specific bucket of the current month.
+
+| params | description |
+| ---------- | -------------------------------------- |
+| bucketName | bucket name |
+| authType | [AuthType](/client/sp-client#authtype) |
+
+```jsx title="example"
+await client.bucket.listBucketReadRecords(
+ {
+ bucketName,
+ startTimeStamp,
+ endTimeStamp,
+ maxRecords: 1000,
+ },
+ {
+ type: 'EDDSA',
+ domain: window.location.origin,
+ seed: offChainData.seedString,
+ address,
+ },
+);
+```
+
+## listBuckets
+
+Lists the bucket info of the user.
+
+| params | description |
+| ------- | ------------ |
+| address | user account |
+
+```jsx title="example"
+const res = await client.bucket.listBuckets({
+ address,
+});
+```
+
+## listBucketsByIds
+
+Lists the bucket info of the user.
+
+| params | description |
+| ------ | ---------------- |
+| ids | bucket ids array |
+
+```jsx title="example"
+await client.bucket.listBucketsByIds({
+ ids: ['1', '2'],
+});
+```
+
+## listBucketsByPaymentAccount
+
+List bucket info by payment account.
+
+| params | description |
+| -------------- | ----------------------- |
+| paymentAccount | payment account address |
+
+```jsx title="example"
+const res = await client.bucket.listBucketsByPaymentAccount({
+ paymentAccount: '0x00...',
+});
+```
+
+## putBucketPolicy
+
+Apply bucket policy to the principal, return the txn hash.
+
+| params | description |
+| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| bucketName | bucket name |
+| statements | Policies outline the specific details of permissions, including the Effect, ActionList, and Resources. |
+| principal | Indicates the marshaled principal content of greenfield permission types, users can generate it by NewPrincipalWithAccount or NewPrincipalWithGroupId method. |
+
+```jsx title="example"
+import { GRNToString, newBucketGRN, PermissionTypes } from '@bnb-chain/greenfield-js-sdk';
+const statement: PermissionTypes.Statement = {
+ effect: PermissionTypes.Effect.EFFECT_ALLOW,
+ actions: [PermissionTypes.ActionType.ACTION_UPDATE_BUCKET_INFO],
+ resources: [GRNToString(newBucketGRN(bucketName))],
+};
+const tx = await client.bucket.putBucketPolicy(bucketName, {
+ operator: address,
+ statements: [statement],
+ principal: {
+ type: PermissionTypes.PrincipalType.PRINCIPAL_TYPE_GNFD_ACCOUNT,
+ value: '0x0000000000000000000000000000000000000001',
+ },
+});
+```
+
+
+
+## updateBucketInfo
+
+Update the bucket meta on chain, including read quota, payment address or visibility. It will send
+the MsgUpdateBucketInfo msg to greenfield to update the meta.
+
+| params | description |
+| ---------------- | ------------------------------------------------------- |
+| bucketName | bucket name |
+| operator | operator account address |
+| visibility | [VisibilityType](/types/visibility) |
+| paymentAddress | payment address |
+| chargedReadQuota | defines the traffic quota that you read from primary sp |
+
+```jsx title="example"
+await client.bucket.updateBucketInfo({
+ bucketName: bucketName,
+ operator: address,
+ visibility: 1,
+ paymentAddress: address,
+ chargedReadQuota: '100',
+});
+```
+
+
diff --git a/doc-site/docs/api/crosschain.md b/doc-site/docs/api/crosschain.md
deleted file mode 100644
index e763bbc7..00000000
--- a/doc-site/docs/api/crosschain.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Crosschain
diff --git a/doc-site/docs/api/crosschain.mdx b/doc-site/docs/api/crosschain.mdx
new file mode 100644
index 00000000..c195b701
--- /dev/null
+++ b/doc-site/docs/api/crosschain.mdx
@@ -0,0 +1,3 @@
+---
+title: 'Crosschain'
+---
diff --git a/doc-site/docs/api/feegrant.md b/doc-site/docs/api/feegrant.md
deleted file mode 100644
index bf73dc7b..00000000
--- a/doc-site/docs/api/feegrant.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-sidebar_position: 6
----
-
-# Feegrant
-
diff --git a/doc-site/docs/api/feegrant.mdx b/doc-site/docs/api/feegrant.mdx
new file mode 100644
index 00000000..b8f6c72b
--- /dev/null
+++ b/doc-site/docs/api/feegrant.mdx
@@ -0,0 +1,3 @@
+---
+title: 'Feegrant'
+---
diff --git a/doc-site/docs/api/gashub.md b/doc-site/docs/api/gashub.md
deleted file mode 100644
index 0e7326a6..00000000
--- a/doc-site/docs/api/gashub.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Gashub
diff --git a/doc-site/docs/api/gashub.mdx b/doc-site/docs/api/gashub.mdx
new file mode 100644
index 00000000..99ff36a2
--- /dev/null
+++ b/doc-site/docs/api/gashub.mdx
@@ -0,0 +1,3 @@
+---
+title: 'Gashub'
+---
diff --git a/doc-site/docs/api/group.md b/doc-site/docs/api/group.md
deleted file mode 100644
index d001ab6a..00000000
--- a/doc-site/docs/api/group.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Group
diff --git a/doc-site/docs/api/group.mdx b/doc-site/docs/api/group.mdx
new file mode 100644
index 00000000..90ae3084
--- /dev/null
+++ b/doc-site/docs/api/group.mdx
@@ -0,0 +1,3 @@
+---
+title: 'Group'
+---
diff --git a/doc-site/docs/api/object.md b/doc-site/docs/api/object.md
deleted file mode 100644
index 6f94c87e..00000000
--- a/doc-site/docs/api/object.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Object
diff --git a/doc-site/docs/api/object.mdx b/doc-site/docs/api/object.mdx
new file mode 100644
index 00000000..0def8463
--- /dev/null
+++ b/doc-site/docs/api/object.mdx
@@ -0,0 +1,3 @@
+---
+title: 'Object'
+---
diff --git a/doc-site/docs/api/overview.mdx b/doc-site/docs/api/overview.mdx
new file mode 100644
index 00000000..4a0fcb08
--- /dev/null
+++ b/doc-site/docs/api/overview.mdx
@@ -0,0 +1,21 @@
+---
+id: api-overview
+title: 'Overview'
+sidebar_position: 1
+---
+
+import ApiTypes from '../../src/components/snippers/api-types.tsx';
+
+The SDK contains three APIs:
+
+-
+
+ send message to greenfield
+
+-
+
+ [query](https://docs.bnbchain.org/greenfield-docs/docs/api/blockchain-rest) info from greenfield.
+
+-
+
+ [more details](https://docs.bnbchain.org/greenfield-docs/docs/api/storage-provider-rest)
diff --git a/doc-site/docs/api/payment.md b/doc-site/docs/api/payment.md
deleted file mode 100644
index 62c497a5..00000000
--- a/doc-site/docs/api/payment.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Payment
diff --git a/doc-site/docs/api/payment.mdx b/doc-site/docs/api/payment.mdx
new file mode 100644
index 00000000..4977328d
--- /dev/null
+++ b/doc-site/docs/api/payment.mdx
@@ -0,0 +1,5 @@
+---
+title: 'Payment'
+---
+
+# Payment
diff --git a/doc-site/docs/api/query-client.md b/doc-site/docs/api/query-client.md
deleted file mode 100644
index 9ba6c3c0..00000000
--- a/doc-site/docs/api/query-client.md
+++ /dev/null
@@ -1,8 +0,0 @@
----
-id: query-client
-sidebar_position: 2
----
-
-# Query Client
-
-
diff --git a/doc-site/docs/api/sp.md b/doc-site/docs/api/sp.md
deleted file mode 100644
index bd8caddf..00000000
--- a/doc-site/docs/api/sp.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Sp
diff --git a/doc-site/docs/api/sp.mdx b/doc-site/docs/api/sp.mdx
new file mode 100644
index 00000000..d5f35f0e
--- /dev/null
+++ b/doc-site/docs/api/sp.mdx
@@ -0,0 +1,5 @@
+---
+title: 'Sp'
+---
+
+
diff --git a/doc-site/docs/api/storage.md b/doc-site/docs/api/storage.md
deleted file mode 100644
index 4e122ec2..00000000
--- a/doc-site/docs/api/storage.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# Storage
diff --git a/doc-site/docs/api/storage.mdx b/doc-site/docs/api/storage.mdx
new file mode 100644
index 00000000..c84063a7
--- /dev/null
+++ b/doc-site/docs/api/storage.mdx
@@ -0,0 +1,5 @@
+---
+title: 'Storage'
+---
+
+
diff --git a/doc-site/docs/api/tx-client.md b/doc-site/docs/api/tx-client.md
deleted file mode 100644
index 585bdbaf..00000000
--- a/doc-site/docs/api/tx-client.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-id: tx-client
-sidebar_position: 1
----
-
-# Tx Client
diff --git a/doc-site/docs/api/virtualGroup.md b/doc-site/docs/api/virtualGroup.md
deleted file mode 100644
index 048e587e..00000000
--- a/doc-site/docs/api/virtualGroup.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-sidebar_position: 6
----
-
-# VirtualGroup
diff --git a/doc-site/docs/api/virtualGroup.mdx b/doc-site/docs/api/virtualGroup.mdx
new file mode 100644
index 00000000..1cd41067
--- /dev/null
+++ b/doc-site/docs/api/virtualGroup.mdx
@@ -0,0 +1,5 @@
+---
+title: 'VirtualGroup'
+---
+
+
diff --git a/doc-site/docs/client/_category_.json b/doc-site/docs/client/_category_.json
new file mode 100644
index 00000000..10c50077
--- /dev/null
+++ b/doc-site/docs/client/_category_.json
@@ -0,0 +1,14 @@
+{
+ "position": 2,
+ "label": "Client",
+ "collapsible": true,
+ "collapsed": true,
+ "className": "red",
+ "link": {
+ "type": "generated-index",
+ "title": "clients"
+ },
+ "customProps": {
+ "description": ""
+ }
+}
\ No newline at end of file
diff --git a/doc-site/docs/client/greenfield.mdx b/doc-site/docs/client/greenfield.mdx
new file mode 100644
index 00000000..10b297e8
--- /dev/null
+++ b/doc-site/docs/client/greenfield.mdx
@@ -0,0 +1,38 @@
+---
+id: greenfield-client
+title: 'Greenfield Client'
+sidebar_position: 1
+---
+
+# Create Greenfield Client
+
+| params | description |
+| -------------- | ------------------- |
+| GRPC_URL | Greenfield grpc url |
+| GREEN_CHAIN_ID | Greenfield chain id |
+
+```js
+import { Client } from '@bnb-chain/greenfield-js-sdk';
+
+// Node.js
+const client = Client.create(GRPC_URL, GREEN_CHAIN_ID);
+
+// Browser
+const client = Client.create(GRPC_URL, String(GREEN_CHAIN_ID), {
+ zkCryptoUrl:
+ 'https://unpkg.com/@bnb-chain/greenfield-zk-crypto@0.0.2-alpha.4/dist/node/zk-crypto.wasm',
+});
+```
+
+:::tip
+
+Browser need load wasm manually.
+
+:::
+
+## Usage
+
+The JS SDK consists of two parts:
+
+- Chain: https://docs.bnbchain.org/greenfield-docs/docs/api/blockchain-rest
+- Storage Provider: https://docs.bnbchain.org/greenfield-docs/docs/api/storage-provider-rest
diff --git a/doc-site/docs/client/query-client.mdx b/doc-site/docs/client/query-client.mdx
new file mode 100644
index 00000000..dcb393db
--- /dev/null
+++ b/doc-site/docs/client/query-client.mdx
@@ -0,0 +1,122 @@
+---
+id: query-client
+title: 'Query Client'
+sidebar_position: 2
+---
+
+It's actually an encapsulation of the
+[Blockchain API](https://docs.bnbchain.org/greenfield-docs/docs/api/blockchain-rest).
+
+:::info
+
+In most cases, you probably don't need to use the ‘Query Client` directly.
+
+:::
+
+## getAuthQueryClient
+
+```jsx title="example"
+const rpc = await client.queryClient.getAuthQueryClient();
+await rpc.Account({
+ address: '0x0000000000000000000000000000000000000001',
+});
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/account-info
+
+## getBankQueryClient
+
+```jsx title="example"
+const rpc = await client.queryClient.getBankQueryClient();
+await rpc.Balance({
+ address: '0x0000000000000000000000000000000000000001',
+ denom: 'BNB',
+});
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/account-info
+
+## getBridgeQueryClient
+
+```jsx title="example"
+const rpc = await client.queryClient.getBridgeQueryClient();
+await rpc.Params();
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/bridge-params
+
+## getChallengeQueryClient
+
+```jsx title="example"
+const rpc = await client.queryClient.getChallengeQueryClient();
+await rpc.Params();
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/attested-challenge
+
+## getCrosschainQueryClient
+
+```jsx title="example"
+const rpc = await client.queryClient.getCrosschainQueryClient();
+await rpc.Params();
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/attested-challenge
+
+## getFeeGrantQueryClient
+
+```jsx title="example"
+const rpc = await client.queryClient.getFeeGrantQueryClient();
+await rpc.Params();
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/allowance
+
+## getGashubClient
+
+```jsx title="example"
+const rpc = await this.queryClient.getGashubClient();
+await rpc.MsgGasParams(request);
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/msg-gas-params
+
+## getPaymentQueryClient
+
+```jsx title="example"
+const rpc = await this.queryClient.getPaymentQueryClient();
+await rpc.Params();
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/msg-gas-params
+
+## getSpQueryClient
+
+```jsx title="example"
+const rpc = await this.queryClient.getSpQueryClient();
+await rpc.Params();
+```
+
+More apis:
+https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/query-global-sp-store-price-by-time
+
+## getStorageQueryClient
+
+```jsx title="example"
+const rpc = await client.queryClient.getStorageQueryClient();
+await rpc.HeadBucketById({
+ bucketId: '1',
+});
+```
+
+More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/query-group-members-exist
+
+## getVirtualGroupClient
+
+```jsx title="example"
+const rpc = await client.queryClient.getVirtualGroupClient();
+await rpc.Params();
+```
+
+More apis:
+https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/available-global-virtual-group-families
diff --git a/doc-site/docs/client/sp-client.mdx b/doc-site/docs/client/sp-client.mdx
new file mode 100644
index 00000000..34aebdc2
--- /dev/null
+++ b/doc-site/docs/client/sp-client.mdx
@@ -0,0 +1,101 @@
+---
+id: sp-client
+sidebar_position: 3
+title: 'Storage Provider Client'
+---
+
+The api related to storage provider are some troublesome.
+
+## AuthType
+
+SDK support two
+[authentication type](https://docs.bnbchain.org/greenfield-docs/docs/api/storage-provider-rest#authentication-type):
+
+- ECDSA: It is usually used on Node.js(Because it need to use a private key)
+- EDDSA: It is usually used in a browser
+
+```jsx title="AuthType"
+/**
+ * ECDSA Signature
+ */
+export type ECDSA = {
+ type: 'ECDSA',
+ privateKey: string,
+};
+/**
+ * EDDSA Signature
+ */
+export type EDDSA = {
+ type: 'EDDSA',
+ seed: string,
+ domain: string,
+ address: string,
+};
+export type AuthType = ECDSA | EDDSA;
+```
+
+
+
+## Sp Api Example
+
+`getBucketReadQuota` as example:
+
+```jsx title="browser"
+const getAllSps = async () => {
+ const sps = await getSps();
+
+ return sps.map((sp) => {
+ return {
+ address: sp.operatorAddress,
+ endpoint: sp.endpoint,
+ name: sp.description?.moniker,
+ };
+ });
+};
+
+// generate seed:
+const allSps = await getAllSps();
+const offchainAuthRes = await client.offchainauth.genOffChainAuthKeyPairAndUpload(
+ {
+ sps: allSps,
+ chainId: GREEN_CHAIN_ID,
+ expirationMs: 5 * 24 * 60 * 60 * 1000,
+ domain: window.location.origin,
+ address: 'your address',
+ },
+ provider: 'wallet provider',
+);
+
+// request sp api
+const bucketQuota = await client.bucket.getBucketReadQuota(
+ {
+ bucketName,
+ },
+ {
+ type: 'EDDSA',
+ seed: offchainAuthRes.seedString,
+ domain: window.location.origin,
+ address: 'your address',
+ },
+);
+```
+
+```jsx title="Nodejs"
+// request sp api
+const bucketQuota = await client.bucket.getBucketReadQuota(
+ {
+ bucketName,
+ },
+ {
+ type: 'ECDSA',
+ privateKey: '0x....',
+ },
+);
+```
diff --git a/doc-site/docs/client/tx-client.mdx b/doc-site/docs/client/tx-client.mdx
new file mode 100644
index 00000000..bc8f1a48
--- /dev/null
+++ b/doc-site/docs/client/tx-client.mdx
@@ -0,0 +1,120 @@
+---
+id: tx-client
+sidebar_position: 1
+title: 'Tx Client'
+---
+
+## About Tx
+
+A transaction contains at least:
+
+1. construct a transaction: The sdk already provides each transaction type
+2. simulate: [txClient.simulate](#simulate)
+3. broadcast [txClient.broadcast](#broadcast)
+
+## simulate
+
+Just Simulate a transaction and valid transaction.
+
+| params | description |
+| ------ | ------------------------------------ |
+| denom | the coin denom to query balances for |
+
+```jsx title="simulate tx"
+// `tx` is a transaction constructed by the sdk
+const simulateInfo = await tx.simulate({
+ denom: 'BNB',
+});
+```
+
+## broadcast
+
+Broadcast the transaction to the chain.
+
+| params | description |
+| --------------------- | ----------------------------------------------------------------------------------------------------------------- |
+| denom | the coin denom to query balances for |
+| gasLimit | can be set to any number, but not too small or the transaction may fail (recommended use `simulateInfo.gasLimit`) |
+| gasPrice | 1 unit of Gas that the transaction sender is willing to pay. |
+| payer | transaction sender |
+| granter | transaction ganter (Generally empty `''`) |
+| signTypedDataCallback | broadcast use `window.ethereum` as signature provider by default. |
+| privateKey | If you broadcast in Nodejs, you can broadcast a tx by privateKey |
+
+```jsx title="broadcast tx"
+// broadcast tx
+const broadcastRes = await transferTx.broadcast({
+ denom: 'BNB',
+ gasLimit: Number(simulateInfo.gasLimit),
+ gasPrice: simulateInfo.gasPrice,
+ payer: '0x0000000000000000000000000000000000000001',
+ granter: '',
+});
+```
+
+:::tip
+
+If you want to use others wallet, you can set `signTypedDataCallback`:
+
+```jsx
+// trustwallet:
+const broadcastRes = await transferTx.broadcast({
+ // ...
+ signTypedDataCallback: async (addr: string, message: string) => {
+ return await window.trustwallet.request({
+ method: 'eth_signTypedData_v4',
+ params: [addr, message],
+ });
+ },
+});
+```
+
+If you broadcast in Nodejs, you can broadcast a tx by privateKey:
+
+```jsx
+const broadcastRes = await transferTx.broadcast({
+ // ...
+ privateKey: '0x.......',
+});
+```
+
+:::
+
+## Example
+
+Take `transfer` tx as an example.
+
+### 1. construct a transaction
+
+```jsx title="construct tx"
+const transferTx = await client.account.transfer({
+ fromAddress: address,
+ toAddress: transferInfo.to,
+ amount: [
+ {
+ denom: 'BNB',
+ amount: '1000000000',
+ },
+ ],
+});
+```
+
+### 2. simulate
+
+```jsx title="simulate tx"
+const simulateInfo = await transferTx.simulate({
+ denom: 'BNB',
+});
+```
+
+### 3. broadcast
+
+```jsx title="broadcast tx"
+const broadcastRes = await transferTx.broadcast({
+ denom: 'BNB',
+ gasLimit: Number(simulateInfo.gasLimit),
+ gasPrice: simulateInfo.gasPrice,
+ payer: address,
+ granter: '',
+});
+```
diff --git a/doc-site/docs/getting-started/client.md b/doc-site/docs/getting-started/client.md
deleted file mode 100644
index c34b1fb0..00000000
--- a/doc-site/docs/getting-started/client.md
+++ /dev/null
@@ -1,28 +0,0 @@
----
-id: create-client
-sidebar_position: 2
----
-
-# Create Greenfield Client
-
-```js
-import { Client } from '@bnb-chain/greenfield-js-sdk'
-
-// Node.js
-const client = Client.create(GRPC_URL, GREEN_CHAIN_ID);
-
-// Browser
-Client.create(GRPC_URL, String(GREEN_CHAIN_ID), {
- zkCryptoUrl:
- 'https://unpkg.com/@bnb-chain/greenfield-zk-crypto@0.0.2-alpha.4/dist/node/zk-crypto.wasm',
-});
-```
-
-> Browser need load wasm manually.
-
-# Usage
-
-The JS SDK consists of two parts:
-
-* Chain: https://docs.bnbchain.org/greenfield-docs/docs/api/blockchain-rest
-* Storage Provider: https://docs.bnbchain.org/greenfield-docs/docs/api/storage-provider-rest
diff --git a/doc-site/docs/getting-started/install.md b/doc-site/docs/getting-started/install.md
deleted file mode 100644
index 3f0a46f8..00000000
--- a/doc-site/docs/getting-started/install.md
+++ /dev/null
@@ -1,24 +0,0 @@
----
-id: install
-sidebar_position: 2
----
-
-# Install
-
-Using npm:
-
-```bash
-> npm install @bnb-chain/greenfield-js-sdk
-```
-
-Using yarn:
-
-```bash
-> yarn add @bnb-chain/greenfield-js-sdk
-```
-
-Using pnpm:
-```bash
-> pnpm add @bnb-chain/greenfield-js-sdk
-```
-
diff --git a/doc-site/docs/getting-started/install.mdx b/doc-site/docs/getting-started/install.mdx
new file mode 100644
index 00000000..19cf18ad
--- /dev/null
+++ b/doc-site/docs/getting-started/install.mdx
@@ -0,0 +1,35 @@
+---
+id: install
+sidebar_position: 2
+title: Install
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+## Install
+
+
+
+
+```bash
+> npm install @bnb-chain/greenfield-js-sdk
+```
+
+
+
+
+```bash
+> yarn add @bnb-chain/greenfield-js-sdk
+```
+
+
+
+
+```bash
+> pnpm add @bnb-chain/greenfield-js-sdk
+```
+
+
+
+
diff --git a/doc-site/docs/getting-started/quick-start.md b/doc-site/docs/getting-started/quick-start.md
index 8f45a206..858d8c46 100644
--- a/doc-site/docs/getting-started/quick-start.md
+++ b/doc-site/docs/getting-started/quick-start.md
@@ -1,6 +1,6 @@
---
id: quick-start
-sidebar_position: 2
+sidebar_position: 3
---
# Quick Start
diff --git a/doc-site/docs/types/visibility-type.mdx b/doc-site/docs/types/visibility-type.mdx
new file mode 100644
index 00000000..e91de1c9
--- /dev/null
+++ b/doc-site/docs/types/visibility-type.mdx
@@ -0,0 +1,23 @@
+---
+id: visibility
+title: VisibilityType
+---
+
+visibility means the bucket is private or public. if private, only bucket owner or grantee can read
+it,otherwise every greenfield user can read it.
+
+## VisibilityType
+
+`VisibilityType` is enum:
+
+```jsx
+/** VisibilityType is the resources public status. */
+export declare enum VisibilityType {
+ VISIBILITY_TYPE_UNSPECIFIED = 0,
+ VISIBILITY_TYPE_PUBLIC_READ = 1,
+ VISIBILITY_TYPE_PRIVATE = 2,
+ /** VISIBILITY_TYPE_INHERIT - If the bucket Visibility is inherit, it's finally set to private. If the object Visibility is inherit, it's the same as bucket. */
+ VISIBILITY_TYPE_INHERIT = 3,
+ UNRECOGNIZED = -1
+}
+```
diff --git a/doc-site/src/components/HomepageFeatures/index.js b/doc-site/src/components/HomepageFeatures/index.js
deleted file mode 100644
index e509a37c..00000000
--- a/doc-site/src/components/HomepageFeatures/index.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/* eslint-disable @typescript-eslint/no-var-requires */
-import React from 'react';
-import clsx from 'clsx';
-import styles from './styles.module.css';
-
-const FeatureList = [
- {
- title: 'Easy to Use',
- Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
- description: (
- <>
- Docusaurus was designed from the ground up to be easily installed and used to get your
- website up and running quickly.
- >
- ),
- },
- {
- title: 'Focus on What Matters',
- Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
- description: (
- <>
- Docusaurus lets you focus on your docs, and we'll do the chores. Go ahead and move your
- docs into the docs
directory.
- >
- ),
- },
- {
- title: 'Powered by React',
- Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
- description: (
- <>
- Extend or customize your website layout by reusing React. Docusaurus can be extended while
- reusing the same header and footer.
- >
- ),
- },
-];
-
-function Feature({ Svg, title, description }) {
- return (
-
-
-
-
-
-
{title}
-
{description}
-
-
- );
-}
-
-export default function HomepageFeatures() {
- return (
-
-
-
- {FeatureList.map((props, idx) => (
-
- ))}
-
-
-
- );
-}
diff --git a/doc-site/src/components/HomepageFeatures/styles.module.css b/doc-site/src/components/HomepageFeatures/styles.module.css
deleted file mode 100644
index b248eb2e..00000000
--- a/doc-site/src/components/HomepageFeatures/styles.module.css
+++ /dev/null
@@ -1,11 +0,0 @@
-.features {
- display: flex;
- align-items: center;
- padding: 2rem 0;
- width: 100%;
-}
-
-.featureSvg {
- height: 200px;
- width: 200px;
-}
diff --git a/doc-site/src/components/account/getAccount.tsx b/doc-site/src/components/account/getAccount.tsx
new file mode 100644
index 00000000..60e7c9da
--- /dev/null
+++ b/doc-site/src/components/account/getAccount.tsx
@@ -0,0 +1,7 @@
+import React from 'react';
+
+const GetAccount = () => {
+ return xx
;
+};
+
+export default GetAccount;
diff --git a/doc-site/src/components/snippers/api-types.tsx b/doc-site/src/components/snippers/api-types.tsx
new file mode 100644
index 00000000..817505ad
--- /dev/null
+++ b/doc-site/src/components/snippers/api-types.tsx
@@ -0,0 +1,21 @@
+import React from 'react';
+type API_TYPE = 'Tx' | 'Query' | 'Storage Provider';
+
+const ApiTypes = (props: { type: API_TYPE }) => {
+ const { type } = props;
+ return (
+
+ {type}
+
+ );
+};
+
+export default ApiTypes;
diff --git a/doc-site/src/components/snippers/tx.mdx b/doc-site/src/components/snippers/tx.mdx
new file mode 100644
index 00000000..784a36e0
--- /dev/null
+++ b/doc-site/src/components/snippers/tx.mdx
@@ -0,0 +1,6 @@
+:::tip
+
+This is only [construct](/client/tx-client) tx, next need [simulate](/client/tx-client#simulate) and
+[broadcast](/client/tx-client#broadcast)
+
+:::
diff --git a/packages/js-sdk/src/api/account.ts b/packages/js-sdk/src/api/account.ts
index 0e098191..23e0cf6e 100644
--- a/packages/js-sdk/src/api/account.ts
+++ b/packages/js-sdk/src/api/account.ts
@@ -34,15 +34,24 @@ export interface IAccount {
*/
getAccountBalance(request: QueryBalanceRequest): Promise;
+ /**
+ * Get all module accounts.
+ */
getModuleAccounts(): Promise;
+ /**
+ * Get module account by module name.
+ */
getModuleAccountByName(name: string): Promise;
/**
- * retrieves all payment accounts owned by the given address
+ * Get all payment accounts owned by the given owner address.
*/
getPaymentAccountsByOwner(owner: string): Promise;
+ /**
+ * Create a new payment account for the given address.
+ */
createPaymentAccount(msg: MsgCreatePaymentAccount): Promise;
/**
diff --git a/packages/js-sdk/src/api/bucket.ts b/packages/js-sdk/src/api/bucket.ts
index 75288311..11cbd7cd 100644
--- a/packages/js-sdk/src/api/bucket.ts
+++ b/packages/js-sdk/src/api/bucket.ts
@@ -181,6 +181,9 @@ export interface IBucket {
putBucketPolicy(bucketName: string, srcMsg: Omit): Promise;
+ /**
+ * Update the bucket meta on chain, including read quota, payment address or visibility. It will send the MsgUpdateBucketInfo msg to greenfield to update the meta.
+ */
updateBucketInfo(
srcMsg: Omit & { chargedReadQuota?: string },
): Promise;
@@ -320,21 +323,21 @@ export class Bucket implements IBucket {
}
public async headBucket(bucketName: string) {
- const rpc = await this.queryClient.getBucketQueryClient();
+ const rpc = await this.queryClient.getStorageQueryClient();
return await rpc.HeadBucket({
bucketName,
});
}
public async headBucketById(bucketId: string) {
- const rpc = await this.queryClient.getBucketQueryClient();
+ const rpc = await this.queryClient.getStorageQueryClient();
return await rpc.HeadBucketById({
bucketId,
});
}
public async headBucketExtra(bucketName: string) {
- const rpc = await this.queryClient.getBucketQueryClient();
+ const rpc = await this.queryClient.getStorageQueryClient();
return await rpc.HeadBucketExtra({
bucketName,
});
@@ -346,7 +349,7 @@ export class Bucket implements IBucket {
}
public async getVerifyPermission(bucketName: string, operator: string, actionType: ActionType) {
- const rpc = await this.queryClient.getBucketQueryClient();
+ const rpc = await this.queryClient.getStorageQueryClient();
return rpc.VerifyPermission({
bucketName,
operator,
diff --git a/packages/js-sdk/src/clients/queryclient.ts b/packages/js-sdk/src/clients/queryclient.ts
index 8326aeb2..98ed08a9 100644
--- a/packages/js-sdk/src/clients/queryclient.ts
+++ b/packages/js-sdk/src/clients/queryclient.ts
@@ -10,10 +10,7 @@ import { QueryClientImpl as BridgeQueryClientImpl } from '@bnb-chain/greenfield-
import { QueryClientImpl as ChallengeQueryClientImpl } from '@bnb-chain/greenfield-cosmos-types/greenfield/challenge/query';
import { QueryClientImpl as PaymentQueryClientImpl } from '@bnb-chain/greenfield-cosmos-types/greenfield/payment/query';
import { QueryClientImpl as SpQueryClientImpl } from '@bnb-chain/greenfield-cosmos-types/greenfield/sp/query';
-import {
- QueryClientImpl as BucketQueryClientImpl,
- QueryClientImpl as StorageQueryClientImpl,
-} from '@bnb-chain/greenfield-cosmos-types/greenfield/storage/query';
+import { QueryClientImpl as StorageQueryClientImpl } from '@bnb-chain/greenfield-cosmos-types/greenfield/storage/query';
import { QueryClientImpl as VirtualGroupClientImpl } from '@bnb-chain/greenfield-cosmos-types/greenfield/virtualgroup/query';
import {
AuthExtension,
@@ -78,11 +75,6 @@ export class RpcQueryClient {
return new PaymentQueryClientImpl(rpcClient);
}
- public async getBucketQueryClient() {
- const rpcClient = await this.getRpcClient();
- return new BucketQueryClientImpl(rpcClient);
- }
-
public async getSpQueryClient() {
const rpcClient = await this.getRpcClient();
return new SpQueryClientImpl(rpcClient);