pledge
pledge
js https://github.com/glitternetwork/glitter-sdk-js/blob/feat-proto-v2/src/client/lcd/Db.ts
No for Python.
The consumer role pledges tokens to high-quality datasets through due diligence and obtains income. The SDK provides a function to implement the pledge operation. The following example demonstrates the operation of pledging tokens to the library library
Python
db_name = "library"
rst = glitter_cli.pledge(db_name, "10000000000000000")
JavaScript
const client = new LCDClient({
chainID: chainId,
URL: url,
gasPrices: gasPrices,
gasAdjustment: gasAdjustment,
});
const key = new MnemonicKey({
mnemonic: mnemonicKey,
account: 0,
index: 0,
});
const dbClient = client.db(key);
const pledgeParams: PledgeRequest = {
fromAddress: key.accAddress,
datasetName: "testcreatedataset",
amount: "1000",
};
const pledgeRst = await dbClient.pledge(pledgeParams);
Golang
cli := New()
ctx := context.Background()
datasetName := "library_test"
amount := sdk.NewInt(1)
resp, err := cli.Pledge(ctx, datasetName, amount)
t.Log(utils.ConvToJSON(resp))
t.Log(err)
release pledge
Consumers can also redeem their mortgaged tokens. The SDK provides a function to implement the redemption operation. The following example demonstrates the redemption operation of the library library
Python
db_name = "library"
rst = glitter_cli.release_pledge(db_name, "1000000000000000000")
JavaScript
const client = new LCDClient({
chainID: chainId,
URL: url,
gasPrices: gasPrices,
gasAdjustment: gasAdjustment,
});
const key = new MnemonicKey({
mnemonic: mnemonicKey,
account: 0,
index: 0,
});
const dbClient = client.db(key);
const releasePledgeParams: PledgeRequest = {
fromAddress: key.accAddress,
datasetName: "testcreatedataset",
amount: "3",
};
const releaseRst = await dbClient.releasePledge(releasePledgeParams);
Golang
cli := New()
ctx := context.Background()
datasetName := "library_test"
amount := sdk.NewInt(1)
resp, err := cli.ReleasePledge(ctx, datasetName, amount)
t.Log(utils.ConvToJSON(resp))
t.Log(err)