Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Substrate.io Migration] - Polkadot Protocol > Protocol Components > Transactions > Transaction and Block Basics #77

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://wss.api.moonbeam.network"
'wss://wss.api.moonbeam.network',
);
const assetApi = new AssetTransferApi(api, specName, safeXcmVersion);

let callInfo;
try {
callInfo = await assetApi.createTransferTransaction(
"2004",
"0xF977814e90dA44bFA03b6295A0616a897441aceC",
'2004',
'0xF977814e90dA44bFA03b6295A0616a897441aceC',
[],
["1000000000000000000"],
['1000000000000000000'],
{
format: "call",
format: 'call',
keepAlive: true,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand All @@ -28,7 +28,7 @@ async function main() {
throw Error(e as string);
}

const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call");
const decoded = assetApi.decodeExtrinsic(callInfo.tx, 'call');
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://moonriver.public.blastapi.io"
'wss://moonriver.public.blastapi.io',
);
const assetApi = new AssetTransferApi(api, specName, safeXcmVersion);
let callInfo;
try {
callInfo = await assetApi.createTransferTransaction(
"2001",
"0xc4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a063",
["vMOVR", "72145018963825376852137222787619937732"],
["1000000", "10000000000"],
'2001',
'0xc4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a063',
['vMOVR', '72145018963825376852137222787619937732'],
['1000000', '10000000000'],
{
format: "call",
format: 'call',
xcmVersion: safeXcmVersion,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand All @@ -27,7 +27,7 @@ async function main() {
throw Error(e as string);
}

const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call");
const decoded = assetApi.decodeExtrinsic(callInfo.tx, 'call');
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://westend-rpc.polkadot.io"
'wss://westend-rpc.polkadot.io',
);
const assetApi = new AssetTransferApi(api, specName, safeXcmVersion);
let callInfo;
try {
callInfo = await assetApi.createTransferTransaction(
"1000",
"5EWNeodpcQ6iYibJ3jmWVe85nsok1EDG8Kk3aFg8ZzpfY1qX",
["WND"],
["1000000000000"],
'1000',
'5EWNeodpcQ6iYibJ3jmWVe85nsok1EDG8Kk3aFg8ZzpfY1qX',
['WND'],
['1000000000000'],
{
format: "call",
format: 'call',
xcmVersion: safeXcmVersion,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand All @@ -27,7 +27,7 @@ async function main() {
throw Error(e as string);
}

const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call");
const decoded = assetApi.decodeExtrinsic(callInfo.tx, 'call');
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"INSERT_WEBSOCKET_URL"
'INSERT_WEBSOCKET_URL',
);

const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://westend-rpc.polkadot.io"
'wss://westend-rpc.polkadot.io',
);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

Expand All @@ -15,12 +15,12 @@ async function main() {
[
`{"parents":"0","interior":{"X2":[{"PalletInstance":"50"},{"GeneralIndex":"1984"}]}}`,
],
["1000000000000"],
"0xf5d5714c084c112843aca74f8c498da06cc5a2d63153b825189baa51043b1f0b",
['1000000000000'],
'0xf5d5714c084c112843aca74f8c498da06cc5a2d63153b825189baa51043b1f0b',
{
format: "call",
format: 'call',
xcmVersion: 2,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://wss.api.moonbeam.network"
'wss://wss.api.moonbeam.network',
);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

let callInfo;
try {
callInfo = await assetsApi.createTransferTransaction(
"2004",
"0xF977814e90dA44bFA03b6295A0616a897441aceC",
'2004',
'0xF977814e90dA44bFA03b6295A0616a897441aceC',
[],
["1000000000000000000"],
['1000000000000000000'],
{
format: "call",
format: 'call',
keepAlive: true,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://wss.api.moonbeam.network"
'wss://wss.api.moonbeam.network',
);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

const encodedExt = "0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600";
const encodedExt = '0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600';

try {
const decodedExt = assetsApi.decodeExtrinsic(encodedExt, "call");
const decodedExt = assetsApi.decodeExtrinsic(encodedExt, 'call');
console.log(
`Decoded tx:\n ${JSON.stringify(JSON.parse(decodedExt), null, 4)}`
`Decoded tx:\n ${JSON.stringify(JSON.parse(decodedExt), null, 4)}`,
);
} catch (e) {
console.error(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://wss.api.moonbeam.network"
'wss://wss.api.moonbeam.network',
);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

const encodedExt = "0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600";
const encodedExt = '0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600';

try {
const decodedExt = await assetsApi.fetchFeeInfo(encodedExt, "call");
const decodedExt = await assetsApi.fetchFeeInfo(encodedExt, 'call');
console.log(`Fee info:\n${JSON.stringify(decodedExt, null, 4)}`);
} catch (e) {
console.error(e);
Expand All @@ -22,4 +22,4 @@ async function main() {

main()
.catch((err) => console.error(err))
.finally(() => process.exit());
.finally(() => process.exit());
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Format = "payload" | "call" | "submittable";
export type Format = 'payload' | 'call' | 'submittable';
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[
[
[
{
"sender": 1000,
"recipient": 2500
}
[
{
"sender": 1000,
"recipient": 2500
}
],
{
"maxCapacity": 8,
"maxTotalSize": 8192,
"maxMessageSize": 1048576,
"msgCount": 0,
"totalSize": 0,
"mqcHead": null,
"senderDeposit": 0,
"recipientDeposit": 0
}
],
{
"maxCapacity": 8,
"maxTotalSize": 8192,
"maxMessageSize": 1048576,
"msgCount": 0,
"totalSize": 0,
"mqcHead": null,
"senderDeposit": 0,
"recipientDeposit": 0
}
],
[
[
{
"sender": 2500,
"recipient": 1000
}
],
{
"maxCapacity": 8,
"maxTotalSize": 8192,
"maxMessageSize": 1048576,
"msgCount": 0,
"totalSize": 0,
"mqcHead": null,
"senderDeposit": 0,
"recipientDeposit": 0
}
]
[
{
"sender": 2500,
"recipient": 1000
}
],
{
"maxCapacity": 8,
"maxTotalSize": 8192,
"maxMessageSize": 1048576,
"msgCount": 0,
"totalSize": 0,
"mqcHead": null,
"senderDeposit": 0,
"recipientDeposit": 0
}
]
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
title: Transactions
nav:
- index.md
- 'Transactions and Block Basis': transactions-and-block-basis.md
Loading