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

Changes related to polkadot-sdk v.1.7.2 and XCM v4 #912

Merged
merged 14 commits into from May 10, 2024
@@ -1,18 +1,18 @@
import ABI from './xtokensABI.js'; // Import the X-Tokens ABI
import { ethers } from 'ethers'; // Import Ethers library
import abi from './xtokensABI.js'; // Import the X-Tokens ABI

const privateKey = 'INSERT_PRIVATE_KEY';

// Create Ethers provider and signer
const provider = new ethers.providers.JsonRpcProvider(
const provider = new ethers.JsonRpcProvider(
'https://rpc.api.moonbase.moonbeam.network'
);
const signer = new ethers.Wallet(privateKey, provider);

// Create X-Tokens contract instance
const xTokens = new ethers.Contract(
'0x0000000000000000000000000000000000000804',
ABI,
abi,
signer
);

Expand All @@ -25,7 +25,7 @@ const dest = [
// Target Alice's 32-byte relay chain account
['0x01c4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a06300'],
];
const weight = 304217000;
const weight = 305986000;

// Sends 1 xcUNIT to the relay chain using the transferMultiasset function
async function transferMultiassetToAlice() {
Expand Down
@@ -1,5 +1,5 @@
import ABI from './xtokensABI.js'; // Import the X-Tokens ABI
import Web3 from 'web3'; // Import Web3 library
import abi from './xtokensABI.js'; // Import the X-Tokens ABI

const privateKey = 'INSERT_PRIVATE_KEY';

Expand All @@ -8,7 +8,7 @@ const web3 = new Web3('https://rpc.api.moonbase.moonbeam.network'); // Change to

// Create contract instance
const xTokens = new web3.eth.Contract(
ABI,
abi,
'0x0000000000000000000000000000000000000804',
{ from: web3.eth.accounts.privateKeyToAccount(privateKey).address } // 'from' is necessary for gas estimation
);
Expand All @@ -22,7 +22,7 @@ const dest = [
// Target Alice's 32-byte relay chain account
['0x01c4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a06300'],
];
const weight = 304217000;
const weight = 305986000;

// Sends 1 xcUNIT to the relay chain using the transferMultiasset function
async function transferMultiassetToAlice() {
Expand Down
Expand Up @@ -21,7 +21,7 @@
# Target Alice's 32-byte relay chain account
["0x01c4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a06300"],
]
weight = 304217000
weight = 305986000


# Sends 1 xcUNIT to the relay chain using the transferMultiasset function
Expand Down
@@ -1,18 +1,18 @@
import ABI from './xtokensABI.js'; // Import the X-Tokens ABI
import { ethers } from 'ethers'; // Import Ethers library
import abi from './xtokensABI.js'; // Import the X-Tokens ABI

const privateKey = 'INSERT_PRIVATE_KEY';

// Create Ethers provider and signer
const provider = new ethers.providers.JsonRpcProvider(
const provider = new ethers.JsonRpcProvider(
'https://rpc.api.moonbase.moonbeam.network'
);
const signer = new ethers.Wallet(privateKey, provider);

// Create X-Tokens contract instance
const xTokens = new ethers.Contract(
'0x0000000000000000000000000000000000000804',
ABI,
abi,
signer
);

Expand All @@ -25,7 +25,7 @@ const destination = [
// Target Alice's 32-byte relay chain account
['0x01c4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a06300'],
];
const weight = 304217000;
const weight = 305986000;

// Sends 1 xcUNIT to the relay chain using the transfer function
async function transferToAlice() {
Expand Down
@@ -1,5 +1,5 @@
import ABI from './xtokensABI.js'; // Import the X-Tokens ABI
import Web3 from 'web3'; // Import Web3 library
import abi from './xtokensABI.js'; // Import the X-Tokens ABI

const privateKey = 'INSERT_PRIVATE_KEY';

Expand All @@ -8,7 +8,7 @@ const web3 = new Web3('https://rpc.api.moonbase.moonbeam.network'); // Change to

// Create contract instance
const xTokens = new web3.eth.Contract(
ABI,
abi,
'0x0000000000000000000000000000000000000804',
{ from: web3.eth.accounts.privateKeyToAccount(privateKey).address } // 'from' is necessary for gas estimation
);
Expand All @@ -22,7 +22,7 @@ const destination = [
// Target Alice's 32-byte relay chain account
['0x01c4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a06300'],
];
const weight = 304217000;
const weight = 305986000;

// Sends 1 xcUNIT to the relay chain using the transfer function
async function transferToAlice() {
Expand Down
Expand Up @@ -21,7 +21,7 @@
# Target Alice's 32-byte relay chain account
["0x01c4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a06300"],
]
weight = 304217000
weight = 305986000

# Sends 1 xcUNIT to the relay chain using the transfer function
def transfer_to_alice():
Expand Down
@@ -1,6 +1,5 @@
<div id="termynal" data-termynal>
eshaben marked this conversation as resolved.
Show resolved Hide resolved
<span data-ty="input">node build-xcm-message.js</span>
<br>
<span data-ty="input"><span class="file-path"></span>node build-xcm-message.js</span>
<span data-ty>Encoded Calldata: 0xb50a04630004000100a10f041000040000000f0000c16ff28623130000000f0000c16ff28623000601070053cd200a02350c007d09260001f0490200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008080000000000000000000000000000000000000000000000000000000000000000110896e292b8000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f000000000000000000000000ed13b028697febd70f34cf9a9e280a8f1e98fd29000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000042004ffd90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042004ffd9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d010000010300f0615483cbe76f5b2aa80a8ce2b2e9a8206deb65</span>
<span data-ty="input"></span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
@@ -1,6 +1,5 @@
<div id="termynal" data-termynal>
eshaben marked this conversation as resolved.
Show resolved Hide resolved
<span data-ty="input">node generate-encoded-calldata.js</span>
<br>
<span data-ty="input"><span class="file-path"></span>node generate-encoded-calldata.js</span>
<span data-ty>Encoded Calldata: 0x260001f0490200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008080000000000000000000000000000000000000000000000000000000000000000110896e292b8000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f000000000000000000000000ed13b028697febd70f34cf9a9e280a8f1e98fd29000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000042004ffd90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042004ffd900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</span>
<span data-ty="input"></span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
@@ -1,7 +1,6 @@
<div id="termynal" data-termynal>
eshaben marked this conversation as resolved.
Show resolved Hide resolved
<span data-ty="input">node send-xcm-message.js</span>
<br>
<span data-ty="input"><span class="file-path"></span>node send-xcm-message.js</span>
<span data-ty>Transaction sent</span>
<span data-ty>Transaction sent</span>
<span data-ty="input"></span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
@@ -1,5 +1,5 @@
import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 9.13.6
import { ethers } from 'ethers'; // Version 6.0.2
import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 10.13.1
import { ethers } from 'ethers'; // Version 6.12.0
import BN from 'bn.js'; // Importing directly from bn.js

// 1. Input Data
Expand All @@ -11,14 +11,14 @@ const contractCall =
const generateCallData = async () => {
// 2. Create Substrate API Provider
const substrateProvider = new WsProvider(providerWsURL);
const ethProvider = new ethers.providers.WebSocketProvider(providerWsURL);
const ethProvider = new ethers.WebSocketProvider(providerWsURL);
const api = await ApiPromise.create({ provider: substrateProvider });

// 3. Estimate Gas for EVM Call
const gasLimit = await ethProvider.estimateGas({
to: uniswapV2Router,
data: contractCall,
value: ethers.utils.parseEther('0.01'),
value: ethers.parseEther('0.01'),
});
console.log(`Gas required for call is ${gasLimit.toString()}`);

Expand All @@ -30,7 +30,7 @@ const generateCallData = async () => {
V2: {
gasLimit: totalGasLimit, // Estimated plus some extra gas
action: { Call: uniswapV2Router }, // Uniswap V2 router address
value: new BN(ethers.utils.parseEther('0.01').toString()), // 0.01 DEV
value: new BN(ethers.parseEther('0.01').toString()), // 0.01 DEV
input: contractCall, // Swap encoded calldata
},
};
Expand Down
@@ -1,6 +1,5 @@
<div id="termynal" data-termynal>
eshaben marked this conversation as resolved.
Show resolved Hide resolved
<span data-ty="input">node build-xcm-message-swap.js</span>
<br>
<span data-ty="input"><span class="file-path"></span>node build-xcm-message-swap.js</span>
<span data-ty>Encoded Calldata: 0x450604630004000100a10f0410000400010403000f0000c16ff286231300010403000f0000c16ff286230006010700902f500982b92a00fd042600019b40090000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f000d01000001030061cd3e07fe7d7f6d4680e3e322986b7877f108dd</span>
<span data-ty="input"></span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
@@ -1,7 +1,7 @@
<div id="termynal" data-termynal>
eshaben marked this conversation as resolved.
Show resolved Hide resolved
<span data-ty="input">node generate-call-data-swap.js</span>
<span data-ty="input"><span class="file-path"></span>node generate-call-data-swap.js</span>
<br>
<span data-ty>Gas required for call is 596363</span>
<span data-ty>Encoded Calldata: 0x2600019b40090000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f00</span>
<span data-ty="input"></span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
@@ -1,3 +1,5 @@
<div id="termynal" data-termynal>
eshaben marked this conversation as resolved.
Show resolved Hide resolved
<span data-ty="input">node send-xcm-message-swap.js</span>
<span data-ty="input"><span class="file-path"></span>node send-xcm-message-swap.js</span>
<span data-ty="input">Transaction included in blockHash 0x4260e32a208dde976c704bb8b08eccd6cdd2cdd9796d79a572c40ba38ce48af6</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
2 changes: 1 addition & 1 deletion builders/build/eth-api/dev-env/scaffold-eth.md
Expand Up @@ -222,7 +222,7 @@ In the following sections, you'll modify the Next.js configuration so that it ta

### Configure the DApp for Moonbeam {: #configure-dapp }

To target the Moonbeam-based network that you deployed your smart contract to, you'll need to edit the configurations in the `packages/nextjs/scaffold.config.ts` file. More specifically, you'll need to modify the `targetNetworks` array in the `scaffoldConfig` object. You can use the [list of chains that viem provides](https://github.com/wevm/viem/blob/main/src/chains/index.ts/){target=\_blank} to specify the chain(s) you've deployed your contract to.
To target the Moonbeam-based network that you deployed your smart contract to, you'll need to edit the configurations in the `packages/nextjs/scaffold.config.ts` file. More specifically, you'll need to modify the `targetNetworks` array in the `scaffoldConfig` object. You can use the [list of chains that viem provides](https://github.com/wevm/viem/blob/main/src/chains/index.ts){target=\_blank} to specify the chain(s) you've deployed your contract to.

=== "Moonbeam"

Expand Down
2 changes: 1 addition & 1 deletion builders/integrations/indexers/thegraph.md
Expand Up @@ -206,7 +206,7 @@ dataSources:

Mappings files are what transform the blockchain data into entities defined in the schema file. Each event handler inside the `subgraph.yaml` file needs to have a subsequent function in the mapping.

The mapping file used for the Lottery example can be found in the [Moonlotto Github Repository](https://github.com/papermoonio/moonlotto-subgraph/blob/main/src/mapping.ts/){target=\_blank}.
The mapping file used for the Lottery example can be found in the [Moonlotto Github Repository](https://github.com/papermoonio/moonlotto-subgraph/blob/main/src/mapping.ts){target=\_blank}.

In general, the strategy of each handler function is to load the event data, check if an entry already exists, arrange the data as desired, and save the entry. For example, the handler function for the `PlayerJoined` event is as follows:

Expand Down