Comments (15)
Token List
path: /token
Request
param type position description
address string query user address
method: GETResponse
{ "code": 200, "data": [ { "uan": "USDT", "displayName": "USDT", "name": "USDT", "decimal": 18, "description": "", "website": "", "icon": "", "url": "", "issuser": "" }, ] }
If mint
and transfer
apis need to use the typeid
and args
fields, perhaps token list
and token detail
need to return the typeid
and args
.
from kuai.
- OmnilockModel
- meta get the meta of omnilock address(capacity)
- mint use ckb to mint sudt
- SudtModel
- meta get the meta data(capacity)
- send collect cell to send sudt
- destory destory all sudt cell
- View
- generateTx generate a tx from inputs and outputs
from kuai.
Database
CREATE `token` (
`id` int not null primary key auto_increment,
`name` varchar(255) not null default '',
`decimal` int not null default 18,
`description` text not null default '',
`website` varchar(255) not null default '',
`icon` varchar(255) not null default '',
`create_tx_hash` varchar(255) not null default '',
`owner_id` int not null,
`args` varchar(255) not null default '',
`created_at` timestamp not null default current_timestamp(),
`updated_at` timestamp not null default current_timestamp() on update current_timestamp(),
unique key `uniq_args` (`args`),
);
CREATE `account` (
`id` int not null primary key auto_increment(),
`address` text not null,
`eth_address` varchar(255) not null,
`created_at` timestamp not null default current_timestamp(),
`updated_at` timestamp not null default current_timestamp() on update current_timestamp()
)
CREATE `holder` (
`id` int not null primary key auto_increment,
`holder_id` int not null,
`token_id` int not null,
`amount` varchar(255) not null default '0',
`created_at` timestamp not null default current_timestamp(),
`updated_at` timestamp not null default current_timestamp() on update current_timestamp(),
key `idx_token_id` (`token_id`),
unique key `uniq_holder_id_token_id` (`holder_id`,`token_id`),
)
CREATE `token_history` (
`id` int not null primary key auto_increment,
`token_id` int not null,
`tx_hash` varchar(255) not null,
`status` int not null default 1 comment '1 - new, 2 - pending, 3 - success',
`from` text not null,
`to` text not null,
`created_at` timestamp not null default current_timestamp(),
`updated_at` timestamp not null default current_timestamp() on update current_timestamp(),
unique key `uniq_token_id_tx_hash` (`token_id`, `tx_hash`)
)
from kuai.
Init backend by kuai init
#457
from kuai.
Sample Kuai Project
This project demonstrates a basic kuai use case.
Run server
npm run build
node ./dist/src/main.js
API Doc
Mint Token
path: /sudt/mint/:typeId
method: POST
Request
{
"from": [""],
"to": "",
"amount": "1000",
}
Response
{
"code": 200,
"data": {
"txSkeleton": "txSkeleton": {
"cellProvider": null,
"cellDeps": [
{
"outPoint": {
"txHash": "0x27b62d8be8ed80b9f56ee0fe41355becdb6f6a40aeba82d3900434f43b1c8b60",
"index": "0x0"
},
"depType": "code"
},
{
"outPoint": {
"txHash": "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",
"index": "0x0"
},
"depType": "depGroup"
},
{
"outPoint": {
"txHash": "0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769",
"index": "0x0"
},
"depType": "code"
}
],
"headerDeps": [],
"inputs": [
{
"cellOutput": {
"capacity": "0x1b41bf852c00",
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"type": null
},
"data": "0x",
"outPoint": {
"txHash": "0x5f2d84f67f378972ba7ee285e4d013450862d31defc121769fbf61fd5810627d",
"index": "0x1"
},
"blockNumber": "0xa66258"
}
],
"outputs": [
{
"cellOutput": {
"capacity": "0x35a4e9000",
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"type": {
"codeHash": "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4",
"hashType": "type",
"args": "0xfb7b6c4a2baf39ebfdd634e76737725362cf18042a31256488382137ae830784"
}
},
"data": "0xa0860100000000000000000000000000"
},
{
"cellOutput": {
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"capacity": "0x1b3e65351560"
},
"data": "0x"
}
],
"witnesses": [
"0x690000001000000069000000690000005500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
],
"fixedEntries": [],
"signingEntries": [],
"inputSinces": {}
}
}
}
Create Token
path: /token
method: POST
Request
{
"code": 200,
"data": {
"name": "USDT",
"account": "", // the address of owner
"decimal": 18,
"description": "",
"website": "",
"icon": "",
"email": ""
}
}
Reponse
{
"code": "201",
"data": {
"txSkeleton": {
"cellProvider": null,
"cellDeps": [
{
"outPoint": {
"txHash": "0x27b62d8be8ed80b9f56ee0fe41355becdb6f6a40aeba82d3900434f43b1c8b60",
"index": "0x0"
},
"depType": "code"
},
{
"outPoint": {
"txHash": "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",
"index": "0x0"
},
"depType": "depGroup"
},
{
"outPoint": {
"txHash": "0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769",
"index": "0x0"
},
"depType": "code"
}
],
"headerDeps": [],
"inputs": [
{
"cellOutput": {
"capacity": "0x1b41bf852c00",
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"type": null
},
"data": "0x",
"outPoint": {
"txHash": "0x5f2d84f67f378972ba7ee285e4d013450862d31defc121769fbf61fd5810627d",
"index": "0x1"
},
"blockNumber": "0xa66258"
}
],
"outputs": [
{
"cellOutput": {
"capacity": "0x35a4e9000",
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"type": {
"codeHash": "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4",
"hashType": "type",
"args": "0xfb7b6c4a2baf39ebfdd634e76737725362cf18042a31256488382137ae830784"
}
},
"data": "0xa0860100000000000000000000000000"
},
{
"cellOutput": {
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"capacity": "0x1b3e65351560"
},
"data": "0x"
}
],
"witnesses": [
"0x690000001000000069000000690000005500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
],
"fixedEntries": [],
"signingEntries": [],
"inputSinces": {}
}
}
}
Update Token
path: /token/:typeId
method: PUT
Request
{
"code": 200,
"data": {
"name": "USDT",
"decimal": 18,
"description": "",
"website": "",
"icon": "",
"explorerCode": "" // the verify code from explorer
}
}
Response
{
"code": 201,
"data": {}
}
Transfer Token
path: /token/transfer
method: POST
Request
{
"typeId": "", // token args
"amount": "",
"to": ""
}
Response
{
"code": 200,
"data": {
"txSkeleton": {
"cellProvider": null,
"cellDeps": [
{
"outPoint": {
"txHash": "0x27b62d8be8ed80b9f56ee0fe41355becdb6f6a40aeba82d3900434f43b1c8b60",
"index": "0x0"
},
"depType": "code"
},
{
"outPoint": {
"txHash": "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",
"index": "0x0"
},
"depType": "depGroup"
},
{
"outPoint": {
"txHash": "0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769",
"index": "0x0"
},
"depType": "code"
}
],
"headerDeps": [],
"inputs": [
{
"cellOutput": {
"capacity": "0x1b41bf852c00",
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"type": null
},
"data": "0x",
"outPoint": {
"txHash": "0x5f2d84f67f378972ba7ee285e4d013450862d31defc121769fbf61fd5810627d",
"index": "0x1"
},
"blockNumber": "0xa66258"
}
],
"outputs": [
{
"cellOutput": {
"capacity": "0x35a4e9000",
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"type": {
"codeHash": "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4",
"hashType": "type",
"args": "0xfb7b6c4a2baf39ebfdd634e76737725362cf18042a31256488382137ae830784"
}
},
"data": "0xa0860100000000000000000000000000"
},
{
"cellOutput": {
"lock": {
"codeHash": "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
"hashType": "type",
"args": "0x00afbf535944be46a2f5879a3a349bc4fd5784a0e900"
},
"capacity": "0x1b3e65351560"
},
"data": "0x"
}
],
"witnesses": [
"0x690000001000000069000000690000005500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
],
"fixedEntries": [],
"signingEntries": [],
"inputSinces": {}
}
}
}
Token List
path: /token
Request
param | type | position | description |
---|---|---|---|
address | string | query | user address |
method: GET
Response
{
"code": 200,
"data": [
{
"uan": "USDT",
"displayName": "USDT",
"name": "USDT",
"decimal": 18,
"description": "",
"website": "",
"icon": "",
"url": "",
"issuser": "",
"args": "",
"typeId": "",
},
]
}
Token Detail
path: /token/:args
method: GET
Response
{
"code": 200,
"data": {
"uan": "USDT",
"displayName": "USDT",
"name": "USDT",
"decimal": 18,
"description": "",
"website": "",
"icon": "",
"url": "",
"issuser": ""
}
}
Asset List
path: /account/:address/assets
method: GET
Request
param | type | position | description |
---|---|---|---|
address | string | query | user address |
Response
{
"code": 200,
"data": [
{
"uan": "USDT",
"displayName": "USDT",
"decimal": 18,
"amount": ""
}
]
}
Token Transfer History
path: /account/:address/assets/transfer/history
method: GET
Response
{
"code": 200,
"data": [
{
"txHash": "",
"from": "",
"to": "",
"time": "",
"status": "",
"sudtAmount": "",
"CKBAmount": "",
"url": "",
}
]
}
from kuai.
Create Token
path: /token
method: POST
Request
{ "symbol": "USDT", "name": "USDT", "amount": "100000", "decimal": "18", "description": "", "website": "", "icon": "" }Reponse
{ "code": 201, "data": { "url": "" // direct to explorer to the transaction to issue the token } }Response
Update Token
path: /token
method: PUT
Request
{ "symbol": "USDT", "name": "USDT", "amount": "100000", "decimal": "18", "description": "", "website": "", "icon": "", "args": "", // sudt args "signature": "" }Response
{ "code": 201, "data": {} }Transfer Token
path: /token/transfer
method: POST
Request
{ "token": "", // token args "amount": "", "to": "" }Token List
path: /token
Request
param type position description
address string query user address
method: GETResponse
[ { "symbol": "USDT", "name": "USDT", "amount": "100000", "decimal": "18", "description": "", "website": "", "icon": "" } ]Token Detail
path: /token/:args
method: GET
Response
{ "symbol": "USDT", "name": "USDT", "amount": "100000", "decimal": "18", "description": "", "website": "", "icon": "", "url": "", "issuser": "" }Asset List
path: /assets
method: GET
Request
param type position description
address string query user addressResponse
{ "code": 200, "data": [ { "symbol": "USDT", "name": "USDT", "amount": "" } ] }Token Transfer History
path: /token/transfer/history
method: GET
Request
param type position description
address string query user addressResponse
[ { "txHash": "", "from": "", "to": "", "time": "", "status": "", "sudtAmount": "", "CKBAmount": "", "url": "", } ]
The response should be canonical, some of them are wrapped with data
that next to code
, some are not.
from kuai.
Update Token
path: /token
method: PUT
Request
{ "code": 200, "data": { "symbol": "USDT", "name": "USDT", "amount": "100000", "decimal": "18", "description": "", "website": "", "icon": "", "args": "", // sudt args "signature": "" } }
What is signature
used for?
from kuai.
Update Token
path: /token
method: PUTRequest
{ "code": 200, "data": { "symbol": "USDT", "name": "USDT", "amount": "100000", "decimal": "18", "description": "", "website": "", "icon": "", "args": "", // sudt args "signature": "" } }
What is
signature
used for?
My mistake, the request should be the same as token update request, I have changed it just now.
{
"code": 200,
"data": {
"symbol": "USDT",
"name": "USDT",
"account": "", // the args of account in omnilock
"supply": "100000",
"decimal": 18,
"description": "",
"website": "",
"icon": "",
"typeId": "",
"args": "", // the args of sudt type script
"explorerCode": "" // the verify code from explorer
}
}
from kuai.
I have changed the API of create token based on the conclusion from last night. Some properties are added and the transaction skeleton will be responded.
from kuai.
There are a few questions I want to confirm
-
Updating tokens:
This api seems to be missing the token identifier, for example, if a user manages multiple tokens, which token is updated when he calls update, I guess the url should bePUT /token/:args
-
Transfer token
Should this api perhaps return aTransaction
? -
Token list & detail
The response type of these two api's seem to be different, but there is only a difference between theissuer
andurl
fields, is it possible to unify them? -
Asset list
Maybe need thedecimal
field -
History:
The front-end page displays the specific tx information and perhaps needs to return the entire tx
![image](https://private-user-images.githubusercontent.com/22258327/276134455-83638cb3-6110-4cff-a04f-1ac97a7d2aa8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE4NzM5MzIsIm5iZiI6MTcyMTg3MzYzMiwicGF0aCI6Ii8yMjI1ODMyNy8yNzYxMzQ0NTUtODM2MzhjYjMtNjExMC00Y2ZmLWEwNGYtMWFjOTdhN2QyYWE4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI1VDAyMTM1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNiYzBlMjZlNzBhZjM0OTE3NjdkNmMzNmM3YWE5ODQ4YzBkYTI0ZTU1YzE2NDIwNTFiMzZlNWU0MWEwYmQ2YzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.K8-WNoIN3bK1SpGvrSRKYhSDxnYksagqB8Gx9Wt0ckU)
![image](https://private-user-images.githubusercontent.com/22258327/276134527-4792c34d-e161-43cf-bd78-33f8b1e64d67.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE4NzM5MzIsIm5iZiI6MTcyMTg3MzYzMiwicGF0aCI6Ii8yMjI1ODMyNy8yNzYxMzQ1MjctNDc5MmMzNGQtZTE2MS00M2NmLWJkNzgtMzNmOGIxZTY0ZDY3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI1VDAyMTM1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU5M2QwYTQxZmFmYmNhZDJiMjA4NGQwMWZhNTY4MjhlMTgwYTNiZTBmZGYzN2YzMzE3MDZhY2JjMjEzMTlkZmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.oQTnGBHwG0iaASpPmmo6HkIirTpo-5xGG8RVhdQg5fI)
And I feel like maybe the mint
api is missing?
Another question, if the frontend has signed the tx through the wallet, how should it be sent to the chain, is it a direct post to the rpc or through the backend?
from kuai.
I think the transaction should send in the front end directly
from kuai.
There are a few questions I want to confirm
- Updating tokens:
This api seems to be missing the token identifier, for example, if a user manages multiple tokens, which token is updated when he calls update, I guess the url should bePUT /token/:args
- Transfer token
Should this api perhaps return aTransaction
?- Token list & detail
The response type of these two api's seem to be different, but there is only a difference between theissuer
andurl
fields, is it possible to unify them?- Asset list
Maybe need thedecimal
field- History:
The front-end page displays the specific tx information and perhaps needs to return the entire tx
![]()
And I feel like maybe themint
api is missing?Another question, if the frontend has signed the tx through the wallet, how should it be sent to the chain, is it a direct post to the rpc or through the backend?
update token
, transfer token
, token list
, token detail
, asset list
has been changed, you can check it.
from kuai.
There are a few questions I want to confirm
- Updating tokens:
This api seems to be missing the token identifier, for example, if a user manages multiple tokens, which token is updated when he calls update, I guess the url should bePUT /token/:args
- Transfer token
Should this api perhaps return aTransaction
?- Token list & detail
The response type of these two api's seem to be different, but there is only a difference between theissuer
andurl
fields, is it possible to unify them?- Asset list
Maybe need thedecimal
field- History:
The front-end page displays the specific tx information and perhaps needs to return the entire tx
![]()
And I feel like maybe themint
api is missing?Another question, if the frontend has signed the tx through the wallet, how should it be sent to the chain, is it a direct post to the rpc or through the backend?
mint
provided
from kuai.
Mint Token
path: /sudt/mint/:typeId
method: POST
Request
{ "from": [""], "to": "", "amount": "1000", }
I'm not sure if only the issuer can mint.
Will there be another address in the from
field?
from kuai.
Mint Token
path: /sudt/mint/:typeId
method: POSTRequest
{ "from": [""], "to": "", "amount": "1000", }
I'm not sure if only the issuer can mint. Will there be another address in the
from
field?
As I learnt from the RFC of sUDT, only issuer could mint more sUDT to others.
from kuai.
Related Issues (20)
- Optimization about Model Pattern
- Release v0.0.1-alpha HOT 4
- Version numbers in mvp and project template are not covered by lerna HOT 6
- Versions in lock file are not bumped correctly HOT 1
- `env-paths` is required in `@ckb-js/kuai-common` but not specified in package.json HOT 2
- Support constructing custom transactions based on outputs of store models
- Technical breakdown of sudt demo HOT 11
- Technical breakdown of sudt demo frontend design HOT 8
- Alias `pattern` as `filter` HOT 1
- Simplify usage of `Lock` decorator
- More useful ideas HOT 3
- Connect sudt management to Neuron by wallet connect HOT 3
- Failed to create new contract in the new project created by kuai init HOT 2
- Add a middleware to transfer the response for default response struct.
- Some problem in developing the sUDT manager HOT 3
- Maybe we need to add states for data HOT 2
- Categorize documents
- Kuai Usage Summary From Acceptance Team HOT 4
- Technical design of account calibration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kuai.