SALP API

Extrinsics

Cross-chain transact from Kusama to Bifrost (Contributors have to cross their KSM to Bifrost for using SALP)

Example
1
2
const theAmount = new BigNumber(amount).multipliedBy(new BigNumber(1000000000000)).toFixed();
3
const paras = [
4
{
5
X1: { Parachain: getEnvs().PARACHAIN_ID },
6
},
7
{
8
X1: {
9
AccountId32: {
10
network: {
11
Any: null,
12
},
13
id: sender,
14
},
15
},
16
},
17
[
18
{
19
ConcreteFungible: {
20
id: {
21
Null: null,
22
},
23
amount: theAmount,
24
},
25
},
26
],
27
3000000,
28
];
29
const transferHandle = await api.tx.xcmPallet.reserveTransferAssets(...paras);
30
const info = await api.tx.xcmPallet.reserveTransferAssets(...paras).paymentInfo(sender);
31
Copied!

Cross-chain transact from Bifrost to Kusama (for users who want to transfer KSM back to the relay-chain)

    api.tx.polkadotXcm.execute
Example
1
2
const theAmount = new BigNumber(amount).multipliedBy(new BigNumber(1000000000000)).toString();
3
const paras = [
4
{
5
WithdrawAsset: {
6
assets: [
7
{
8
ConcreteFungible: {
9
id: {
10
X1: {
11
Parent: null,
12
},
13
},
14
amount: theAmount,
15
},
16
},
17
],
18
effects: [
19
{
20
BuyExecution: {
21
fees: {
22
All: null,
23
},
24
weight: 0,
25
debt: 3000000000,
26
haltOnError: false,
27
xcm: [],
28
},
29
},
30
{
31
InitiateReserveWithdraw: {
32
assets: [
33
{
34
All: null,
35
},
36
],
37
reserve: {
38
X1: {
39
Parent: null,
40
},
41
},
42
effects: [
43
{
44
BuyExecution: {
45
fees: {
46
All: null,
47
},
48
weight: 0,
49
debt: 3000000000,
50
haltOnError: false,
51
xcm: [],
52
},
53
},
54
{
55
DepositAsset: {
56
assets: [
57
{
58
All: null,
59
},
60
],
61
dest: {
62
X1: {
63
AccountId32: {
64
network: {
65
Any: null,
66
},
67
id: receiver,
68
},
69
},
70
},
71
},
72
},
73
],
74
},
75
},
76
],
77
},
78
},
79
3000000000,
80
];
81
const transferHandle = await api.tx.polkadotXcm.execute(...paras);
82
const info = await api.tx.polkadotXcm.execute(...paras).paymentInfo(sender);
83
Copied!

Bifrost call contribute

    api.tx.salp.contribute:
      Authentication: User’s signature address
      Parameter:
        index: ParaId; // Contribute to a paraid
        value: Balance; // The amount of contribution
      Description: The user calls this function to contribute to a fund (ongoing).
Example
1
2
const keyring = new Keyring({type: 'sr25519'});
3
4
const provider = new WsProvider(BIFROST_END_POINT);
5
const api = await ApiPromise.create(options({provider: provider}));
6
7
const sudo = keyring.addFromUri(BIFROST_SUDO_PHRASE);
8
9
const extrinsic = api.tx.salp.contribute(PARA_ID, BALANCE);
10
const ext_hash = await extrinsic.signAndSend(sudo);
11
Copied!

Parachain auciton fail, call refund function manually

    api.tx.salp.refund:
      Authentication: User’s signature address
      Parameter:
        index: ParaId; // The paraId needs to refund
      Description: When the fund fails and the funds have been withdrawable, the user can redeem the contributed funds with the locked vsToken/vsBond.
Example

Call the redeem function when parachain fund retired.

    api.tx.salp.redeem:
      Authentication: User’s signature address
      Parameter:
        index: ParaId; // vsbond Parameter: paraId
        value: Balance; // redeem amount
      Description: When the user holds the vsbond that reaches the redemption period, the combination of vsbond + vsToken can be used to redeem the underlaying KSM, which will be sent to the user’s address on relay chain.
Example

Storage

Query for Bifrost assets

    api.query.tokens.accounts:
      Parameter:
        0: AccountId; // query the address
        1: CurrencyId; // type of assets
      Description: Query an address’s assets amount.

Query vsKSM,vsBond total issuance

    api.query.tokens.totalIssuance:
      Parameter:
        0: CurrencyId; // type of assets
      Description: Query assets amount of a paraId.

Query a specific fund info

    api.query.salp.funds:
      Parameter:
        0: ParaId; // Parachain ID
      Description: Query the fund info of a paraId.

Query the contribution info of a user

    rpc interface
      Parameter:
        0: ParaId; // Parachain ID
        1: AccountId; //ss58 account address
      Description: Query the contribution info of an user.
1
2
curl http://localhost:29999 -H "Content-Type:application/json;charset=utf-8" -d '{"jsonrpc":"2.0","id":1,"method":"salp_getContribution","params": [2001, "Hsjp321vR7quo4ETVyuUFbrJMddW7K7qPndtxCZHzY1CCHA"]}'
3
Copied!

Bifrost Service

salp_contributed

    graphql API
      Parameter:
        account; //ss58 bifrost account address
        para_id; //ParaId
      Description:Query the contribution details of a certain ParaId/or the contribution details of a certain user address. (Deleting account means to query all the contribution details of a ParaId.)
1
2
query {
3
salp_contributed(
4
account:"ftEXBzn7nKfUsoDRtw39AUMGdwQY37SMPuC6HEXkPmN1cvf",
5
para_id:"2088"
6
){
7
para_id
8
balance
9
account
10
block_timestamp
11
block_height
12
}
13
}
14
Copied!
Last modified 7d ago