Skip to content

Latest commit

 

History

History
121 lines (105 loc) · 3.15 KB

token.md

File metadata and controls

121 lines (105 loc) · 3.15 KB

PLUGCHAIN SDK GO

TOKEN MODULE

realization

Query

QueryToken

Query a single token

token, err := client.Token.QueryToken("test1")

QueryTokens

Query all tokens

token, err := client.Token.QueryTokens("")

QueryFees

Inquiry fee

token, err := client.Token.QueryFees("test1")

QueryParams

Query parameters

res, err := client.Token.QueryParams()

TX

IssueToken

Issue tokens You need to import the private key before you can operate,Please see the key package for importing the private key

baseTx := types.BaseTx{
    From:     "demo", //Account name 
    Password: "123123123",
    Gas:      200000,
    Mode:     types.Commit,
    Memo:     "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000plug") //Fee
issueTokenReq := token.IssueTokenRequest{
	Symbol:        "test1",
	Name:          "testToken",
	Scale:         8,
	MinUnit:       "tt1",
	InitialSupply: 10000000,
	MaxSupply:     21000000,
	Mintable:      true,
}
rs, err := client.Token.IssueToken(issueTokenReq, baseTx)

EditToken

Modify token You need to import the private key before you can operate,Please see the key package for importing the private key

baseTx := types.BaseTx{
    From:     "demo", //Account name 
    Password: "123123123",
    Gas:      200000,
    Mode:     types.Commit,
    Memo:     "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000plug") //Fee
editTokenReq := token.EditTokenRequest{
    Symbol:    "test1",
    Name:      "testToken66",
    MaxSupply: 22000000,
}
rs, err := client.Token.EditToken(editTokenReq, baseTx)

TransferToken

Transfer token ownership You need to import the private key before you can operate,Please see the key package for importing the private key

baseTx := types.BaseTx{
    From:     "demo", //Account name 
    Password: "123123123",
    Gas:      200000,
    Mode:     types.Commit,
    Memo:     "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000plug") //Fee
rs, err := client.Token.TransferToken("gx1akqhezuftdcc0eqzkq5peqpjlucgmyr7srx54j", "test1", baseTx)

MintToken

Coinage token You need to import the private key before you can operate,Please see the key package for importing the private key

baseTx := types.BaseTx{
    From:     "demo", //Account name 
    Password: "123123123",
    Gas:      200000,
    Mode:     types.Commit,
    Memo:     "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000plug") //Fee
rs, err = client.Token.MintToken("test1", 11000000, "gx1yhf7w0sq8yn6gqre2pulnqwyy30tjfc4v08f3x", baseTx)