diff --git a/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/compile.md b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/compile.md new file mode 100644 index 000000000..b6fa88cc5 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/compile.md @@ -0,0 +1,13 @@ +
+ npx hardhat compile + Compiled 1 Solidity files successfully (evm target: paris). + ls -l + artifacts + cache + contracts + hardhat.config.js + node_modules + package.json + package-lock.json + +
diff --git a/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/deploy-moonbase.md b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/deploy-moonbase.md new file mode 100644 index 000000000..c5678f6c0 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/deploy-moonbase.md @@ -0,0 +1,18 @@ +
+ npx hardhat ignition deploy ./ignition/modules/Box.js --network moonbase +
+ βœ… Confirm deploy to network moonbase (1287)? … yes + Hardhat Ignition πŸš€ +
+ Deploying [ BoxModule ] +
+ Batch #1 + Executed BoxModule#Box +
+ [ BoxModule ] successfully deployed πŸš€ +
+ Deployed Addresses +
+ BoxModule#Box - 0xfBD78CE8C9E1169851119754C4Ea2f70AB159289 + +
diff --git a/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/hardhat-create.md b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/hardhat-create.md new file mode 100644 index 000000000..6d319ce09 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/hardhat-create.md @@ -0,0 +1,20 @@ +
+ npx hardhat init + 888    888                      888 888               888 + 888    888                      888 888               888 + 888    888                      888 888               888 + 8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888 + 888    888     "88b 888P"  d88" 888 888 "88b     "88b 888 + 888    888 .d888888 888    888  888 888  888 .d888888 888 + 888    888 888  888 888    Y88b 888 888  888 888  888 Y88b. + 888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888 +
+ πŸ‘· Welcome to Hardhat v2.22.2 πŸ‘·β€ +
+  What do you want to do? … +   Create a JavaScript project +   Create a TypeScript project +   Create a TypeScript project (with Viem) + +   Quit +
\ No newline at end of file diff --git a/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/interact.md b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/interact.md new file mode 100644 index 000000000..5236e3d05 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/interact.md @@ -0,0 +1,36 @@ +
+ npx hardhat console --network moonbase +
+ Welcome to Node.js v20.9.0. + Type ".help" for more information. + const Box = await ethers.getContractFactory('Box'); + undefined +
+ const box = await Box.attach('0xfBD78CE8C9E1169851119754C4Ea2f70AB159289'); + undefined +
+ await box.store(5); + ContractTransactionResponse {
+ provider: HardhatEthersProvider { ... },
+ blockNumber: null,
+ blockHash: null,
+ index: undefined,
+ hash: '0x1c49a64a601fc5dd184f0a368a91130cb49203ec0f533c6fcf20445c68e20264',
+ type: 2,
+ to: '0xa84caB60db6541573a091e5C622fB79e175E17be',
+ from: '0x3B939FeaD1557C741Ff06492FD0127bd287A421e',
+ nonce: 87,
+ gasLimit: 45881n,
+ gasPrice: 1107421875n,
+ maxPriorityFeePerGas: 1n,
+ maxFeePerGas: 1107421875n,
+ data: '0x6057361d0000000000000000000000000000000000000000000000000000000000000005',
+ value: 0n,
+ chainId: 5678n,
+ signature: Signature { r: "0x9233b9cc4ae6879b7e08b9f1a4bfb175c8216eee0099966eca4a305c7f369ecc", s: "0x7663688633006b5a449d02cb08311569fadf2f9696bd7fe65417860a3b5fc57d", yParity: 0, networkV: null },
+ accessList: [],
+ blobVersionedHashes: null
}
+ await box.retrieve(); + 5n +
+
diff --git a/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/private-keys.md b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/private-keys.md new file mode 100644 index 000000000..15127b6e6 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/private-keys.md @@ -0,0 +1,26 @@ +
+ Private Key: Oxdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 + Account #9: Oxa0Ee7A142d267C1f36714E4a8F75612F20a79720 (10000 ETH) + Private Key: 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 + Account #10: OxBcd4042DE499D14e55001CcbB24a551F3b954096 (10000 ETH) + Private Key: Oxf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897 + Account #11: 0x71bE63f3384f5fb98995898A86B02Fb2426c5788 (10000 ETH) + Private Key: 0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82 + Account #12: OxFABBOac9d68B0B445fB7357272F202C5651694a (10000 ETH) + Private Key: Oxa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1 + Account #13: 0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec (10000 ETH) + Private Key: 0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd + Account #14: OxdF3e18d64BC6A983f673Ab319CCaE4f1a5707097 (10000 ETH) + Private Key: Oxc526ee95bf44d8fc405a158bb884d9d1238d990612e9f33d006bb0789009aaa + Account #15: Oxcd3B766CCDd6AE721141F452C550Ca635964ce71 (10000 ETH) + Private Key: 0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61 + Account #16: 0Γ—2546BcD3c84621e976D8185a91A922aE77ECEc30 (10000 ETH) + Private Key: Oxea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0 + Account #17: OxbDA5747bFD65F08deb54cb465eB87D40e51B197E (10000 ETH) + Private Key: 0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b06166765a93e037fd + Account #18: OxdD2FD4581271e230360230F9337D5c0430Bf44C0 (10000 ETH) + Private Key: Oxde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0 + Account #19: 0Γ—8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199 (10000 ETH) + Private Key: Oxdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e + WARNING: These accounts, and their private keys, are publicly known.
Any funds sent to them on Mainnet or any other live network WILL BE LOST.
+
diff --git a/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/run.md b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/run.md new file mode 100644 index 000000000..492d0d3d3 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/hardhat/terminal/run.md @@ -0,0 +1,6 @@ +
+ npx hardhat run --network moonbase scripts/set-value.js +
+ The new value is: 2 + +
diff --git a/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC1155.sol b/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC1155.sol new file mode 100644 index 000000000..37b003d75 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC1155.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +// Compatible with OpenZeppelin Contracts ^5.0.0 +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol"; + +contract MyToken is ERC1155, Ownable, ERC1155Pausable { + constructor() ERC1155("") Ownable() { + _mint(msg.sender, 0, 1000 * 10 ** 18, ""); + _mint(msg.sender, 1, 1, ""); + } + + function setURI(string memory newuri) public onlyOwner { + _setURI(newuri); + } + + function pause() public onlyOwner { + _pause(); + } + + function unpause() public onlyOwner { + _unpause(); + } + + // The following function is an override required by Solidity + function _update(address from, address to, uint256[] memory ids, uint256[] memory values) + internal + override(ERC1155, ERC1155Pausable) + { + super._update(from, to, ids, values); + } +} \ No newline at end of file diff --git a/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC20.sol b/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC20.sol new file mode 100644 index 000000000..d4db50797 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC20.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +// Compatible with OpenZeppelin Contracts ^5.0.0 +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; + +contract MyToken is ERC20, Ownable, ERC20Permit { + constructor(address initialOwner) + ERC20("MyToken", "MTK") + Ownable(initialOwner) + ERC20Permit("MyToken") + { + _mint(msg.sender, 1000 * 10 ** decimals()); + } + + function mint(address to, uint256 amount) public onlyOwner { + _mint(to, amount); + } +} \ No newline at end of file diff --git a/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC721.sol b/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC721.sol new file mode 100644 index 000000000..299b8a942 --- /dev/null +++ b/.snippets/code/builders/build/eth-api/dev-env/openzeppelin/ERC721.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +// Compatible with OpenZeppelin Contracts ^5.0.0 +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; + +contract MyToken is ERC721, ERC721Enumerable, ERC721Burnable, Ownable { + constructor(address initialOwner) + ERC721("MyToken", "MTK") + Ownable(initialOwner) + {} + + function _baseURI() internal pure override returns (string memory) { + return "Test"; + } + + function safeMint(address to, uint256 tokenId) public onlyOwner { + _safeMint(to, tokenId); + } + + // The following functions are overrides required by Solidity + function _update(address to, uint256 tokenId, address auth) + internal + override(ERC721, ERC721Enumerable) + returns (address) + { + return super._update(to, tokenId, auth); + } + + function _increaseBalance(address account, uint128 value) + internal + override(ERC721, ERC721Enumerable) + { + super._increaseBalance(account, value); + } + + function supportsInterface(bytes4 interfaceId) + public + view + override(ERC721, ERC721Enumerable) + returns (bool) + { + return super.supportsInterface(interfaceId); + } +} \ No newline at end of file diff --git a/.snippets/code/builders/get-started/networks/moonbeam-dev/terminal/docker-pull.md b/.snippets/code/builders/get-started/networks/moonbeam-dev/terminal/docker-pull.md index f60d286c3..67fb49557 100644 --- a/.snippets/code/builders/get-started/networks/moonbeam-dev/terminal/docker-pull.md +++ b/.snippets/code/builders/get-started/networks/moonbeam-dev/terminal/docker-pull.md @@ -1,16 +1,16 @@
- docker pull moonbeamfoundation/moonbeam:v0.36.0 + docker pull moonbeamfoundation/moonbeam:v0.37.2
- v0.36.0: Pulling from moonbeamfoundation/moonbeam -
e1caac4eb9d2: Pull complete -
303f0b059437: Pull complete -
1987eeb667a4: Pull complete -
c2b8e919bd5a: Pull complete -
c6a7952896a0: Pull complete -
3ad97e77096a: Pull complete -
a5e5655dbb4f: Pull complete -
Digest: sha256:099e885c4601c8f7ba4408492f2df142920a794baf019cf71cf3a3a16810f504 -
Status: Downloaded newer image for moonbeamfoundation/moonbeam:v0.36.0 -
docker.io/moonbeamfoundation/moonbeam:v0.36.0 + v0.37.2: Pulling from moonbeamfoundation/moonbeam +
b0a0cf830b12: Pull complete +
fbff687640dd: Pull complete +
58ea427410e2: Pull complete +
811ba55e6e61: Pull complete +
4316d5f1b914: Pull complete +
128693ce218e: Pull complete +
a3ac90b88463: Pull complete +
Digest: sha256:1def3370159ee7d14fce3951a1198bda7c51af566e0b3d69ce4644338e29f046 +
Status: Downloaded newer image for moonbeamfoundation/moonbeam:v0.37.2 +
docker.io/moonbeamfoundation/moonbeam:v0.37.2
diff --git a/.snippets/code/builders/get-started/networks/moonbeam-dev/terminal/docker-run.md b/.snippets/code/builders/get-started/networks/moonbeam-dev/terminal/docker-run.md index 115c584b5..dad5be5ac 100644 --- a/.snippets/code/builders/get-started/networks/moonbeam-dev/terminal/docker-run.md +++ b/.snippets/code/builders/get-started/networks/moonbeam-dev/terminal/docker-run.md @@ -1,38 +1,38 @@
docker run --rm --name moonbeam_development --network host \ -
moonbeamfoundation/moonbeam:v0.36.0 \ +
moonbeamfoundation/moonbeam:v0.37.2 \
--dev --rpc-external

CLI parameter `--execution` has no effect anymore and will be removed in the future! -
2024-02-27 06:09:29 Moonbeam Parachain Collator -
2024-02-27 06:09:29 ✌️ 0.36.0-d1087f30917 -
2024-02-27 06:09:29 ❀️ by PureStake, 2019-2024 -
2024-02-27 06:09:29 πŸ“‹ Chain specification: Moonbase Development Testnet -
2024-02-27 06:09:29 🏷 Node name: black-and-white-sticks-9174 -
2024-02-27 06:09:29 πŸ‘€ Role: AUTHORITY -
2024-02-27 06:09:29 πŸ’Ύ Database: RocksDb at /tmp/substrateO3YeRz/chains/moonbase_dev/db/full -
2024-02-27 06:09:40 πŸ”¨ Initializing Genesis block/state (state: 0x7c34…99c5, header-hash: 0xa083…f354) -
2024-02-27 06:09:40 Using default protocol ID "sup" because none is configured in the chain specs -
2024-02-27 06:09:40 🏷 Local node identity is: 12D3KooWLcpczme2JeBEfLqmjqkzYVKTGKhhGmwSzHjRXGBVhDX7 -
2024-02-27 06:09:40 πŸ’» Operating system: linux -
2024-02-27 06:09:40 πŸ’» CPU architecture: x86_64 -
2024-02-27 06:09:40 πŸ’» Target environment: gnu -
2024-02-27 06:09:40 πŸ’» CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz -
2024-02-27 06:09:40 πŸ’» CPU cores: 12 -
2024-02-27 06:09:40 πŸ’» Memory: 7946MB -
2024-02-27 06:09:40 πŸ’» Kernel: 6.4.16-linuxkit -
2024-02-27 06:09:40 πŸ’» Linux distribution: Debian GNU/Linux 12 (bookworm) -
2024-02-27 06:09:40 πŸ’» Virtual machine: yes -
2024-02-27 06:09:40 πŸ“¦ Highest known block at #0 -
2024-02-27 06:09:40 Running JSON-RPC server: addr=0.0.0.0:9944, allowed origins=["*"] -
2024-02-27 06:09:40 🏁 CPU score: 1.14 GiBs -
2024-02-27 06:09:40 〽️ Prometheus exporter started at 127.0.0.1:9615 -
2024-02-27 06:09:40 🏁 Memory score: 10.41 GiBs -
2024-02-27 06:09:40 🏁 Disk score (seq. writes): 987.96 MiBs -
2024-02-27 06:09:40 🏁 Disk score (rand. writes): 363.65 MiBs -
2024-02-27 06:09:40 Development Service Ready -
2024-02-27 06:09:45 πŸ’€ Idle (0 peers), best: #0 (0xa083…f354), finalized #0 (0xa083…f354), ⬇ 0 ⬆ 0 -
2024-02-27 06:09:50 πŸ’€ Idle (0 peers), best: #0 (0xa083…f354), finalized #0 (0xa083…f354), ⬇ 0 ⬆ 0 +
2024-04-29 06:09:29 Moonbeam Parachain Collator +
2024-04-29 06:09:29 ✌️ 0.37.2-be5032c7749 +
2024-04-29 06:09:29 ❀️ by PureStake, 2019-2024 +
2024-04-29 06:09:29 πŸ“‹ Chain specification: Moonbase Development Testnet +
2024-04-29 06:09:29 🏷 Node name: black-and-white-sticks-9174 +
2024-04-29 06:09:29 πŸ‘€ Role: AUTHORITY +
2024-04-29 06:09:29 πŸ’Ύ Database: RocksDb at /tmp/substrateO3YeRz/chains/moonbase_dev/db/full +
2024-04-29 06:09:40 πŸ”¨ Initializing Genesis block/state (state: 0xf7c4…5c0f, header-hash: 0x42bd…3b5b) +
2024-04-29 06:09:40 Using default protocol ID "sup" because none is configured in the chain specs +
2024-04-29 06:09:40 🏷 Local node identity is: 12D3KooWLcpczme2JeBEfLqmjqkzYVKTGKhhGmwSzHjRXGBVhDX7 +
2024-04-29 06:09:40 πŸ’» Operating system: linux +
2024-04-29 06:09:40 πŸ’» CPU architecture: x86_64 +
2024-04-29 06:09:40 πŸ’» Target environment: gnu +
2024-04-29 06:09:40 πŸ’» CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz +
2024-04-29 06:09:40 πŸ’» CPU cores: 12 +
2024-04-29 06:09:40 πŸ’» Memory: 7946MB +
2024-04-29 06:09:40 πŸ’» Kernel: 6.4.16-linuxkit +
2024-04-29 06:09:40 πŸ’» Linux distribution: Debian GNU/Linux 12 (bookworm) +
2024-04-29 06:09:40 πŸ’» Virtual machine: yes +
2024-04-29 06:09:40 πŸ“¦ Highest known block at #0 +
2024-04-29 06:09:40 Running JSON-RPC server: addr=0.0.0.0:9944, allowed origins=["*"] +
2024-04-29 06:09:40 🏁 CPU score: 1.14 GiBs +
2024-04-29 06:09:40 〽️ Prometheus exporter started at 127.0.0.1:9615 +
2024-04-29 06:09:40 🏁 Memory score: 10.41 GiBs +
2024-04-29 06:09:40 🏁 Disk score (seq. writes): 987.96 MiBs +
2024-04-29 06:09:40 🏁 Disk score (rand. writes): 363.65 MiBs +
2024-04-29 06:09:40 Development Service Ready +
2024-04-29 06:09:45 πŸ’€ Idle (0 peers), best: #0 (0xa083…f354), finalized #0 (0xa083…f354), ⬇ 0 ⬆ 0 +
2024-04-29 06:09:50 πŸ’€ Idle (0 peers), best: #0 (0xa083…f354), finalized #0 (0xa083…f354), ⬇ 0 ⬆ 0
diff --git a/.snippets/code/builders/interoperability/xcm/remote-execution/remote-evm-calls/send.js b/.snippets/code/builders/interoperability/xcm/remote-execution/remote-evm-calls/send.js index 5ac95b642..20a1fe49c 100644 --- a/.snippets/code/builders/interoperability/xcm/remote-execution/remote-evm-calls/send.js +++ b/.snippets/code/builders/interoperability/xcm/remote-execution/remote-evm-calls/send.js @@ -3,7 +3,7 @@ import { cryptoWaitReady } from '@polkadot/util-crypto'; // 1. Input data const providerWsURL = - 'wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network'; + 'wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network'; const privateKey = 'INSERT_PRIVATE_KEY'; const dest = { V3: { parents: 0, interior: { X1: { Parachain: 1000 } } } }; const instr1 = { diff --git a/.snippets/code/builders/json-rpc/debug-trace/terminal/start-up-logs.md b/.snippets/code/builders/json-rpc/debug-trace/terminal/start-up-logs.md new file mode 100644 index 000000000..9bea6dfdf --- /dev/null +++ b/.snippets/code/builders/json-rpc/debug-trace/terminal/start-up-logs.md @@ -0,0 +1,25 @@ +
+ docker run --network host \ +
-u $(id -u ${USER}):$(id -g ${USER}) \ + moonbeamfoundation/moonbeam-tracing:v0.37.2-2902-latest \ +
--name="Moonbean-Tracing-Tutorial" \ +
--unsafe-rpc-external \ +
--ethapi=debug,trace,txpool \ +
--wasm-runtime-overrides=/moonbeam/moonbase-substitutes-tracing \ +
--runtime-cache-size 64 \ +
--dev +
+
+ CLI parameter `--execution` has no effect anymore and will be removed in the future! +
2024-04-29 13:52:00 Moonbeam Parachain Collator +
2024-04-29 13:52:00 ✌️ version 0.37.2-be5032c7749 +
2024-04-29 13:52:00 ❀️ by PureStake, 2019-2024 +
2024-04-29 13:52:00 πŸ“‹ Chain specification: Moonbase Development Testnet +
2024-04-29 13:52:00 🏷 Node name: Moonbean-Tracing-Tutorial +
2024-04-29 13:52:00 πŸ‘€ Role: AUTHORITY +
2024-04-29 13:52:00 πŸ’Ύ Database: RocksDb at /tmp/substrateO3YeRz/chains/moonbase_dev/db/full +
2024-04-29 14:52:13 Found wasm override. version=moonbase-300 (moonbase-0.tx2.au3) file=/moonbeam/moonbase-substitutes-tracing/moonbase-runtime-300-substitute-tracing.wasm +
... +
2024-04-29 14:56:34 πŸ’€ Idle (0 peers), best: #0 (0x18e6…2eb1), finalized #0 (0x18e6…2eb1), ⬇ 0 ⬆ 0 +
+
diff --git a/.snippets/code/builders/build/eth-api/pubsub/subscribe-to-event-logs.js b/.snippets/code/builders/json-rpc/pubsub/subscribe-to-event-logs.js similarity index 100% rename from .snippets/code/builders/build/eth-api/pubsub/subscribe-to-event-logs.js rename to .snippets/code/builders/json-rpc/pubsub/subscribe-to-event-logs.js diff --git a/.snippets/code/builders/build/eth-api/pubsub/use-wildcards.js b/.snippets/code/builders/json-rpc/pubsub/use-wildcards.js similarity index 100% rename from .snippets/code/builders/build/eth-api/pubsub/use-wildcards.js rename to .snippets/code/builders/json-rpc/pubsub/use-wildcards.js diff --git a/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/ethers-relay-data-verifier.js b/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/ethers-relay-data-verifier.js index 5db18efbd..6c5179bd8 100644 --- a/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/ethers-relay-data-verifier.js +++ b/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/ethers-relay-data-verifier.js @@ -9,7 +9,7 @@ const abi = JSON.parse(fs.readFileSync('./RelayChainDataVerifierABI.json')); const privateKey = 'INSERT_PRIVATE_KEY'; const precompileAddress = '0x0000000000000000000000000000000000000819'; const moonbeamURL = 'https://rpc.api.moonbase.moonbeam.network'; -const relayURL = 'wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network'; +const relayURL = 'wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network'; // Create Ethers provider and signer const provider = new ethers.JsonRpcProvider(moonbeamURL); diff --git a/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/web3js-relay-data-verifier.js b/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/web3js-relay-data-verifier.js index cd33040c6..a02770792 100644 --- a/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/web3js-relay-data-verifier.js +++ b/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/web3js-relay-data-verifier.js @@ -9,7 +9,7 @@ const abi = JSON.parse(fs.readFileSync('./RelayChainDataVerifierABI.json')); const privateKey = 'INSERT_PRIVATE_KEY'; const precompileAddress = '0x0000000000000000000000000000000000000819'; const moonbeamURL = 'https://rpc.api.moonbase.moonbeam.network'; -const relayURL = 'wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network'; +const relayURL = 'wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network'; // Create Web3js provider and signer const web3 = new Web3(moonbeamURL); diff --git a/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/web3py-relay-data-verifier.py b/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/web3py-relay-data-verifier.py index 659ff5d85..d354713b7 100644 --- a/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/web3py-relay-data-verifier.py +++ b/.snippets/code/builders/pallets-precompiles/precompiles/relay-data-verifier/web3py-relay-data-verifier.py @@ -9,7 +9,7 @@ privateKey = "INSERT_PRIVATE_KEY" precompileAddress = "0x0000000000000000000000000000000000000819" moonbeamURL = "https://rpc.api.moonbase.moonbeam.network" -relayURL = "wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network" +relayURL = "wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network" # Create provider for Moonbeam network web3 = Web3(Web3.HTTPProvider(moonbeamURL)) diff --git a/.snippets/code/node-operators/networks/tracing-node/terminal/logs.md b/.snippets/code/node-operators/networks/tracing-node/terminal/logs.md new file mode 100644 index 000000000..40effd8ab --- /dev/null +++ b/.snippets/code/node-operators/networks/tracing-node/terminal/logs.md @@ -0,0 +1,14 @@ +
+ asm override. version=moonbase-400 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/moo nbase-runtime-400-substitute-tracing.wasm +
Jun 03 12:45:55 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:45:55 [πŸŒ—] Found w asm override. version-moonbase-155 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/moo + nbase-runtime-155-substitute-tracing. wasm +
Jun 03 12:45:56 vmi719182. contaboserver.net moonbase [2115]: 2022-06-03 12:45:56 [πŸŒ—] Found w asm override. version-moonbase-501 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/moo nbase-runtime-501-substitute-tracing.wasm +
Jun 03 12:45:57 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:45:57 [πŸŒ—] Found w asm override. version-moonbase-1200 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/mo onbase-runtime-1200-substitute-tracing.wasm +
Jun 03 12:45:58 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:45:58 [πŸŒ—] Found w asm override. version-moonbase-47 (moonbase-1.tx2.au3) file=/var/lib/alphanet-data/wasm/moon base-runtime-47-substitute-tracing.wasm +
Jun 03 12:46:00 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:46:00 [πŸŒ—] Found w asm override. version=moonbase-1501 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/mo onbase-runtime-1501-substitute-tracing.wasm +
Jun 03 12:46:01 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:46:01 [πŸŒ—] Found w asm override. version-moonbase-900 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/moo nbase-runtime-900-substitute-tracing.wasm +
Jun 03 12:46:04 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:46:04 [πŸŒ—] Found w asm override. version-moonbase-1504 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/mo onbase-runtime-1504-substitute-tracing.wasm +
Jun 03 12:46:05 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:46:05 [πŸŒ—] Found w asm override. version-moonbase-1101 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/mo onbase-runtime-1101-substitute-tracing.wasm +
Jun 03 12:46:07 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:46:07 [πŸŒ—] Found w asm override. version-moonbase-800 (moonbase-0.tx2.au3) file=/var/lib/alphanet-data/wasm/moo nbase-runtime-800-substitute-tracing.wasm +
+
diff --git a/.snippets/code/node-operators/networks/tracing-node/terminal/status.md b/.snippets/code/node-operators/networks/tracing-node/terminal/status.md new file mode 100644 index 000000000..392547be8 --- /dev/null +++ b/.snippets/code/node-operators/networks/tracing-node/terminal/status.md @@ -0,0 +1,24 @@ +
+ systemctl status moonbeam.service + ● moonbeam.service - "Moonbase Alpha systemd service" +
Loaded: loaded (/etc/systemd/system/moonbeam.service; enabled; vendor preset: enabled) +
Active: active (running) since Fri 2022-06-03 12:45:08 EDT; 10min ago +
Main PID: 2115 (moonbeam) +
Tasks: 43 (limit: 19141) +
Memory: 9.5G +
CGroup:/system.slice/moonbeam.service +
--2115 /var/lib/alphanet-data/moonbeam --port 30334 --rpc-port 9944 +
+
+ Jun 03 12:55:07 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:07 [πŸŒ—] > +
Jun 03 12:55:08 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:08 [Rela> +
Jun 03 12:55:12 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:12 [πŸŒ—] > +
Jun 03 12:55:13 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:13 [Rela> +
Jun 03 12:55:17 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:17 [πŸŒ—] > +
Jun 03 12:55:18 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:18 [Rela> +
Jun 03 12:55:19 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:19 [Rela> +
Jun 03 12:55:19 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:19 [Rela> +
Jun 03 12:55:19 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:19 [Rela> +
Jun 03 12:55:19 vmi719182.contaboserver.net moonbase [2115]: 2022-06-03 12:55:19 [Rela> +
+
diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/DelegationDAO.sol b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/DelegationDAO.sol index 35a27a8a5..3064634f9 100644 --- a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/DelegationDAO.sol +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/DelegationDAO.sol @@ -4,11 +4,10 @@ pragma solidity >=0.8.0; import "./StakingInterface.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; -import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; + contract DelegationDAO is AccessControl { - using SafeMath for uint256; // Role definition for contract members bytes32 public constant MEMBER = keccak256("MEMBER"); @@ -56,20 +55,25 @@ contract DelegationDAO is AccessControl { // Initialize a new DelegationDao dedicated to delegating to the given collator target. constructor(address _target, address admin) { + // Directly grant roles + _grantRole(DEFAULT_ADMIN_ROLE, admin); + _grantRole(MEMBER, admin); + //Sets the collator that this DAO nominating target = _target; // Initializes Moonbeam's parachain staking precompile staking = ParachainStaking(stakingPrecompileAddress); - //Initializes Roles - _setupRole(DEFAULT_ADMIN_ROLE, admin); - _setupRole(MEMBER, admin); - //Initialize the DAO state currentState = daoState.COLLECTING; } + // Simple getter to return the target collator of the DAO + function getTarget() public view returns (address) { + return target; + } + // Grant a user the role of admin function grant_admin( address newAdmin @@ -99,13 +103,13 @@ contract DelegationDAO is AccessControl { if (!staking.isDelegator(address(this))) { revert("The DAO is in an inconsistent state."); } - memberStakes[msg.sender] = memberStakes[msg.sender].add(msg.value); - totalStake = totalStake.add(msg.value); + memberStakes[msg.sender] = memberStakes[msg.sender] + msg.value; + totalStake = totalStake + msg.value; emit deposit(msg.sender, msg.value); staking.delegatorBondMore(target, msg.value); } else if (currentState == daoState.COLLECTING) { - memberStakes[msg.sender] = memberStakes[msg.sender].add(msg.value); - totalStake = totalStake.add(msg.value); + memberStakes[msg.sender] = memberStakes[msg.sender] + msg.value; + totalStake = totalStake + msg.value; emit deposit(msg.sender, msg.value); if (totalStake < minDelegationStk) { return; @@ -144,16 +148,13 @@ contract DelegationDAO is AccessControl { } require(totalStake != 0, "Cannot divide by zero."); //Calculate the withdrawal amount including staking rewards - uint amount = address(this) - .balance - .mul(memberStakes[msg.sender]) - .div(totalStake); + uint amount = address(this).balance * memberStakes[msg.sender] / totalStake; require( check_free_balance() >= amount, "Not enough free balance for withdrawal." ); Address.sendValue(account, amount); - totalStake = totalStake.sub(memberStakes[msg.sender]); + totalStake = totalStake - (memberStakes[msg.sender]); memberStakes[msg.sender] = 0; emit withdrawal(msg.sender, account, amount); } @@ -210,4 +211,9 @@ contract DelegationDAO is AccessControl { function reset_dao() public onlyRole(DEFAULT_ADMIN_ROLE) { currentState = daoState.COLLECTING; } + + // Override _setupRole to use grantRole as _setupRole does not exist in AccessControl anymore + function _setupRole(bytes32 role, address account) internal virtual { + grantRole(role, account); + } } diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/dao-js-test-file.js b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/dao-js-test-file.js index 391ada329..d285fa0fc 100644 --- a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/dao-js-test-file.js +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/dao-js-test-file.js @@ -4,76 +4,90 @@ const { ethers } = require('hardhat'); const { expect } = require('chai'); // Indicate the collator the DAO wants to delegate to -const targetCollator = '0x4c5A56ed5A4FF7B09aA86560AfD7d383F4831Cce'; +// For Moonbase Local Node, use: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac +// For Moonbase Alpha, use: 0x12E7BCCA9b1B15f33585b5fc898B967149BDb9a5 +const targetCollator = 'INSERT_COLLATOR_ADDRESS'; // The describe function receives the name of a section of your test suite, and a // callback. The callback must define the tests of that section. This callback // can't be an async function describe('Dao contract', function () { - async function deployDao() { - // Get the contract factory and signers here - const [deployer, member1] = await ethers.getSigners(); - const delegationDao = await ethers.getContractFactory('DelegationDAO'); + let wallet1, wallet2; - // Deploy the staking DAO and wait for the deployment transaction to be confirmed - const deployedDao = await delegationDao.deploy( - targetCollator, - deployer.address + before(async function () { + // Get signers we defined in Hardhat config + const signers = await ethers.getSigners(); + wallet1 = signers[0]; + wallet2 = signers[1]; + }); + + async function deployDao() { + const delegationDaoFactory = await ethers.getContractFactory( + 'DelegationDAO', + wallet2 ); - await deployedDao.waitForDeployment(); - // Return the deployed DAO and the first member of the DAO to allow the tests to - // access and interact with them - return { deployedDao, member1 }; + // Deploy the staking DAO and wait for the deployment transaction to be confirmed + try { + const deployedDao = await delegationDaoFactory.deploy( + targetCollator, + wallet2.address + ); + await deployedDao.waitForDeployment(); // Correct way to wait for the transaction to be mined + return { deployedDao }; + } catch (error) { + console.error('Failed to deploy contract:', error); + return null; // Return null to indicate failure + } } - // You can nest calls to create subsections describe('Deployment', function () { - // Mocha's it function is used to define each of your tests. - // It receives the test name, and a callback function - // - // If the callback function is async, Mocha will await it + // Test case to check that the correct target collator is stored it('should store the correct target collator in the DAO', async function () { - // Set up our test environment by calling deployDao - const { deployedDao } = await deployDao(); - - // The expect function receives a value and wraps it in an assertion object. - // This test will pass if the DAO stored the correct target collator - expect(await deployedDao.target()).to.equal(targetCollator); + const deployment = await deployDao(); + if (!deployment || !deployment.deployedDao) { + throw new Error('Deployment failed; DAO contract was not deployed.'); + } + const { deployedDao } = deployment; + expect(await deployedDao.getTarget()).to.equal( + '0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac' + ); }); - // The following test cases should be added here + // Test case to check that the DAO has 0 funds at inception it('should initially have 0 funds in the DAO', async function () { const { deployedDao } = await deployDao(); - - // This test will pass if the DAO has no funds as expected before any contributions expect(await deployedDao.totalStake()).to.equal(0); }); + // Test case to check that non-admins cannot grant membership it('should not allow non-admins to grant membership', async function () { - const { deployedDao, member1 } = await deployDao(); + const { deployedDao } = await deployDao(); + // Connect the non-admin wallet to the deployed contract + const deployedDaoConnected = deployedDao.connect(wallet1); + const tx = deployedDaoConnected.grant_member( + '0x0000000000000000000000000000000000000000' + ); - // We use connect to call grant_member from member1's account instead of admin. - // This test will succeed if the function call reverts and fails if the call succeeds - await expect( - deployedDao - .connect(member1) - .grant_member('0x0000000000000000000000000000000000000000') - ).to.be.reverted; + // Check that the transaction reverts, not specifying any particular reason + await expect(tx).to.be.reverted; }); + // Test case to check that members can access member only functions it('should only allow members to access member-only functions', async function () { - const { deployedDao, member1 } = await deployDao(); + const { deployedDao } = await deployDao(); - // Add a new member to the DAO - const transaction = await deployedDao.grant_member(member1.address); - await transaction.wait(); + // Connect the wallet1 to the deployed contract and grant membership + const deployedDaoConnected = deployedDao.connect(wallet2); + const grantTx = await deployedDaoConnected.grant_member(wallet1.address); + await grantTx.wait(); - // This test will succeed if the DAO member can call the member-only function. - // We use connect here to call the function from the account of the new member - expect(await deployedDao.connect(member1).check_free_balance()).to.equal( - 0 - ); + // Check the free balance using the member's credentials + const checkTx = deployedDaoConnected.check_free_balance(); + + // Since check_free_balance() does not modify state, we expect it not to be reverted and check the balance + await expect(checkTx).to.not.be.reverted; + expect(await checkTx).to.equal(0); }); }); }); diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/compile.md b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/compile.md new file mode 100644 index 000000000..1774656c6 --- /dev/null +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/compile.md @@ -0,0 +1,5 @@ +
+ npx hardhat compile + Compiled 8 Solidity files successfully (evm target: paris). + +
diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/deploy-moonbase.md b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/deploy-moonbase.md new file mode 100644 index 000000000..0f392b3a6 --- /dev/null +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/deploy-moonbase.md @@ -0,0 +1,18 @@ +
+ npx hardhat ignition deploy ./ignition/modules/DelegationDao.js --network moonbase --deployment-id INSERT_YOUR_NAME +
+ βœ… Confirm deploy to network moonbase (1287)? … yes + Hardhat Ignition πŸš€ +
+ Deploying [ DelegationDAOModule ] +
+ Batch #1 + Executed DelegationDAOModule#DelegationDAO +
+ [ DelegationDAOModule ] successfully deployed πŸš€ +
+ Deployed Addresses +
+ DelegationDAOModule#DelegationDAO - 0x69c555fE1A8D0916E6dab0629bd7530D4d2Be4D1 + +
diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/deploy-moonbeam.md b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/deploy-moonbeam.md new file mode 100644 index 000000000..e658b4ece --- /dev/null +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/deploy-moonbeam.md @@ -0,0 +1,18 @@ +
+ npx hardhat ignition deploy ./ignition/modules/DelegationDao.js --network moonbeam --deployment-id INSERT_YOUR_NAME +
+ βœ… Confirm deploy to network moonbeam (1284)? … yes + Hardhat Ignition πŸš€ +
+ Deploying [ DelegationDAOModule ] +
+ Batch #1 + Executed DelegationDAOModule#DelegationDAO +
+ [ DelegationDAOModule ] successfully deployed πŸš€ +
+ Deployed Addresses +
+ DelegationDAOModule#DelegationDAO - 0x6D895A55F5ba31e582bCEe71cae394266F240e9b + +
diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/hardhat-create.md b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/hardhat-create.md new file mode 100644 index 000000000..6d319ce09 --- /dev/null +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/hardhat-create.md @@ -0,0 +1,20 @@ +
+ npx hardhat init + 888    888                      888 888               888 + 888    888                      888 888               888 + 888    888                      888 888               888 + 8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888 + 888    888     "88b 888P"  d88" 888 888 "88b     "88b 888 + 888    888 .d888888 888    888  888 888  888 .d888888 888 + 888    888 888  888 888    Y88b 888 888  888 888  888 Y88b. + 888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888 +
+ πŸ‘· Welcome to Hardhat v2.22.2 πŸ‘·β€ +
+  What do you want to do? … +   Create a JavaScript project +   Create a TypeScript project +   Create a TypeScript project (with Viem) + +   Quit +
\ No newline at end of file diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/test.md b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/test.md new file mode 100644 index 000000000..5ffe0c324 --- /dev/null +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/test.md @@ -0,0 +1,15 @@ +
+ npx hardhat test --network dev tests/Dao.js +
+
+ Dao contract + Deployment + βœ… The DAO should store the correct target collator (1624ms) + βœ… The DAO should initially have 0 funds in it + βœ… Non-admins should not be able to grant membership (150ms) + βœ… DAO members should be able to access member only functions (132ms) +
+
+ βœ… 4 passing (2s) + +
diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/verify-moonbase.md b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/verify-moonbase.md new file mode 100644 index 000000000..54775a5d9 --- /dev/null +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/verify-moonbase.md @@ -0,0 +1,12 @@ +
+ npx hardhat ignition verify INSERT_YOUR_NAME +
+ Nothing to compile + Successfully submitted source code for contract +contracts/DelegationDAO.sol:DelegationDAO at 0x5D788B98E4A90F9642352B0b32694998e77cF4d7 for verification on the block explorer. Waiting for verification result... +
+ Successfully verified contract DelegationDAO on Etherscan. +
+ https://moonbase.moonscan.io/address/0x5D788B98E4A90F9642352B0b32694998e77cF4d7#code + +
diff --git a/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/verify-moonbeam.md b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/verify-moonbeam.md new file mode 100644 index 000000000..332a94c7f --- /dev/null +++ b/.snippets/code/tutorials/eth-api/hardhat-start-to-end/terminal/verify-moonbeam.md @@ -0,0 +1,12 @@ +
+ npx hardhat ignition verify INSERT_YOUR_NAME +
+ Nothing to compile + Successfully submitted source code for contract +contracts/DelegationDAO.sol:DelegationDAO at 0x6D895A55F5ba31e582bCEe71cae394266F240e9b for verification on the block explorer. Waiting for verification result... +
+ Successfully verified contract DelegationDAO on Etherscan. +
+ https://moonbeam.moonscan.io/address/0x6D895A55F5ba31e582bCEe71cae394266F240e9b#code + +
diff --git a/.snippets/code/tutorials/interoperability/remote-batched-evm-calls/build-xcm-message.js b/.snippets/code/tutorials/interoperability/remote-batched-evm-calls/build-xcm-message.js index 03fda0b79..621572e53 100644 --- a/.snippets/code/tutorials/interoperability/remote-batched-evm-calls/build-xcm-message.js +++ b/.snippets/code/tutorials/interoperability/remote-batched-evm-calls/build-xcm-message.js @@ -2,7 +2,7 @@ import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 9.13.6 // 1. Input Data const providerWsURL = - 'wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network'; + 'wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network'; const amountToWithdraw = BigInt(1 * 10 ** 16); // 0.01 DEV const devMultiLocation = { parents: 0, diff --git a/.snippets/code/tutorials/interoperability/remote-batched-evm-calls/send-xcm-message.js b/.snippets/code/tutorials/interoperability/remote-batched-evm-calls/send-xcm-message.js index e10c04026..003703f7c 100644 --- a/.snippets/code/tutorials/interoperability/remote-batched-evm-calls/send-xcm-message.js +++ b/.snippets/code/tutorials/interoperability/remote-batched-evm-calls/send-xcm-message.js @@ -3,7 +3,7 @@ import Keyring from '@polkadot/keyring'; // Version 10.3.1 // 1. Input Data const providerWsURL = - 'wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network'; + 'wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network'; const MNEMONIC = 'INSERT_MNEMONIC'; // Not safe, only for testing const txCall = '0xcd0a04630003000100a10f031000040000010403000f0000c16ff28623130000010403000f0000c16ff28623000601070053cd200a02350c007d09260001f0490200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008080000000000000000000000000000000000000000000000000000000000000000110896e292b8000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f000000000000000000000000ed13b028697febd70f34cf9a9e280a8f1e98fd29000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000042004ffd90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042004ffd9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d010000010300f0615483cbe76f5b2aa80a8ce2b2e9a8206deb65'; diff --git a/.snippets/code/tutorials/interoperability/remote-staking/remote-staking.js b/.snippets/code/tutorials/interoperability/remote-staking/remote-staking.js index 0c2f57141..3829524cd 100644 --- a/.snippets/code/tutorials/interoperability/remote-staking/remote-staking.js +++ b/.snippets/code/tutorials/interoperability/remote-staking/remote-staking.js @@ -43,7 +43,7 @@ const message = { const performRemoteDelegation = async () => { // 2. Construct API provider const wsProvider = new WsProvider( - 'wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network' + 'wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network' ); const api = await ApiPromise.create({ provider: wsProvider }); diff --git a/.snippets/code/tutorials/interoperability/uniswapv2-swap/build-xcm-message.js b/.snippets/code/tutorials/interoperability/uniswapv2-swap/build-xcm-message.js index f3d88acfb..54e590f26 100644 --- a/.snippets/code/tutorials/interoperability/uniswapv2-swap/build-xcm-message.js +++ b/.snippets/code/tutorials/interoperability/uniswapv2-swap/build-xcm-message.js @@ -1,7 +1,7 @@ import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 9.13.6 // 1. Input Data -const providerWsURL = 'wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network'; +const providerWsURL = 'wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network'; const amountToWithdraw = BigInt(1 * 10 ** 16); // 0.01 DEV const devMultiLocation = { parents: 0, interior: { X1: { PalletInstance: 3 } } }; const weightTransact = 40000000000n; // 25000 * Gas limit of EVM call diff --git a/.snippets/code/tutorials/interoperability/uniswapv2-swap/send-xcm-message.js b/.snippets/code/tutorials/interoperability/uniswapv2-swap/send-xcm-message.js index 84b5ef221..561c2ee54 100644 --- a/.snippets/code/tutorials/interoperability/uniswapv2-swap/send-xcm-message.js +++ b/.snippets/code/tutorials/interoperability/uniswapv2-swap/send-xcm-message.js @@ -2,7 +2,7 @@ import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 9.13.6 import Keyring from '@polkadot/keyring'; // Version 10.3.1 // 1. Input Data -const providerWsURL = 'wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network'; +const providerWsURL = 'wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network'; const MNEMONIC = 'INSERT_MNEMONIC'; // Not safe, only for testing const txCall = '0x4d0604630003000100a10f031000040000010403000f0000c16ff28623130000010403000f0000c16ff286230006010700902f500982b92a00fd04260001eeed020000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f000d01000001030061cd3e07fe7d7f6d4680e3e322986b7877f108dd'; diff --git a/.snippets/text/builders/get-started/endpoints/moonbase.md b/.snippets/text/builders/get-started/endpoints/moonbase.md index 78d05ac75..8f64e95aa 100644 --- a/.snippets/text/builders/get-started/endpoints/moonbase.md +++ b/.snippets/text/builders/get-started/endpoints/moonbase.md @@ -1,23 +1,26 @@ === "HTTPS" - | Provider | RPC URL | - |:-------------------:|:----------------------------------------------------------:| - | Blast |
```https://moonbase-alpha.public.blastapi.io```
| - | Dwellir |
```https://moonbase-rpc.dwellir.com```
| - | Moonbeam Foundation |
```https://rpc.api.moonbase.moonbeam.network```
| - | UnitedBloc |
```https://moonbase.unitedbloc.com```
| + | Provider | RPC URL | Limits | + |:-------------------:|:----------------------------------------------------------------:|:----------:| + | Blast |
```https://moonbase-alpha.public.blastapi.io```
| 80 req/sec | + | Dwellir |
```https://moonbase-rpc.dwellir.com```
| 20 req/sec | + | OnFinality |
```https://moonbeam-alpha.api.onfinality.io/public```
| 40 req/sec | + | Moonbeam Foundation |
```https://rpc.api.moonbase.moonbeam.network```
| 25 req/sec | + | UnitedBloc |
```https://moonbase.unitedbloc.com```
| 32 req/sec | === "WSS" - | Provider | RPC URL | - |:-------------------:|:--------------------------------------------------------:| - | Blast |
```wss://moonbase-alpha.public.blastapi.io```
| - | Dwellir |
```wss://moonbase-rpc.dwellir.com```
| - | Moonbeam Foundation |
```wss://wss.api.moonbase.moonbeam.network```
| - | UnitedBloc |
```wss://moonbase.unitedbloc.com```
| + | Provider | RPC URL | Limits | + |:-------------------:|:-----------------------------------------------------------------:|:----------:| + | Blast |
```wss://moonbase-alpha.public.blastapi.io```
| 80 req/sec | + | Dwellir |
```wss://moonbase-rpc.dwellir.com```
| 20 req/sec | + | OnFinality |
```wss://moonbeam-alpha.api.onfinality.io/public-ws```
| 40 req/sec | + | Moonbeam Foundation |
```wss://wss.api.moonbase.moonbeam.network```
| 25 req/sec | + | UnitedBloc |
```wss://moonbase.unitedbloc.com```
| 32 req/sec | + #### Relay Chain {: #relay-chain } To connect to the Moonbase Alpha relay chain, you can use the following WS Endpoint: -| Provider | RPC URL | -|:---------:|:-----------------------------------------------------------------------------:| -| PureStake |
```wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network```
| \ No newline at end of file +| Provider | RPC URL | +|:--------:|:------------------------------------------------------------------------------------:| +| OpsLayer |
```wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network```
| diff --git a/.snippets/text/builders/get-started/endpoints/moonbeam.md b/.snippets/text/builders/get-started/endpoints/moonbeam.md index eec111844..3b1ff7f96 100644 --- a/.snippets/text/builders/get-started/endpoints/moonbeam.md +++ b/.snippets/text/builders/get-started/endpoints/moonbeam.md @@ -1,15 +1,18 @@ === "HTTPS" - | Provider | RPC URL | - |:------------:|:---------------------------------------------------------------------------------------------:| - | 1RPC |
```https://1rpc.io/glmr```
| - | Blast |
```https://moonbeam.public.blastapi.io```
| - | Dwellir |
```https://moonbeam-rpc.dwellir.com```
| - | POKT Network |
```https://moonbeam-mainnet.gateway.pokt.network/v1/lb/629a2b5650ec8c0039bb30f0```
| - | UnitedBloc |
```https://moonbeam.unitedbloc.com```
| + | Provider | RPC URL | Limits | + |:------------:|:---------------------------------------------------------------------------------------------:|:-----------:| + | 1RPC |
```https://1rpc.io/glmr```
| Unspecified | + | Blast |
```https://moonbeam.public.blastapi.io```
| 80 req/sec | + | Dwellir |
```https://moonbeam-rpc.dwellir.com```
| 20 req/sec | + | OnFinality |
```https://moonbeam.api.onfinality.io/public```
| 40 req/sec | + | POKT Network |
```https://moonbeam-mainnet.gateway.pokt.network/v1/lb/629a2b5650ec8c0039bb30f0```
| 25 req/sec | + | UnitedBloc |
```https://moonbeam.unitedbloc.com```
| 32 req/sec | + === "WSS" - | Provider | RPC URL | - |:----------:|:--------------------------------------------------:| - | Blast |
```wss://moonbeam.public.blastapi.io```
| - | Dwellir |
```wss://moonbeam-rpc.dwellir.com```
| - | UnitedBloc |
```wss://moonbeam.unitedbloc.com```
| + | Provider | RPC URL | Limits | + |:----------:|:-----------------------------------------------------------:|:----------:| + | Blast |
```wss://moonbeam.public.blastapi.io```
| 80 req/sec | + | Dwellir |
```wss://moonbeam-rpc.dwellir.com```
| 20 req/sec | + | OnFinality |
```wss://moonbeam.api.onfinality.io/public-ws```
| 40 req/sec | + | UnitedBloc |
```wss://moonbeam.unitedbloc.com```
| 32 req/sec | diff --git a/.snippets/text/builders/get-started/endpoints/moonriver.md b/.snippets/text/builders/get-started/endpoints/moonriver.md index 8d6dd7c65..0db062c4d 100644 --- a/.snippets/text/builders/get-started/endpoints/moonriver.md +++ b/.snippets/text/builders/get-started/endpoints/moonriver.md @@ -1,14 +1,16 @@ === "HTTPS" - | Provider | RPC URL | - |:------------:|:----------------------------------------------------------------------------------------------:| - | Blast |
```https://moonriver.public.blastapi.io```
| - | Dwellir |
```https://moonriver-rpc.dwellir.com```
| - | POKT Network |
```https://moonriver-mainnet.gateway.pokt.network/v1/lb/62a74fdb123e6f003963642f```
| - | UnitedBloc |
```https://moonriver.unitedbloc.com```
| + | Provider | RPC URL | Limits | + |:------------:|:----------------------------------------------------------------------------------------------:|:----------:| + | Blast |
```https://moonriver.public.blastapi.io```
| 80 req/sec | + | Dwellir |
```https://moonriver-rpc.dwellir.com```
| 20 req/sec | + | OnFinality |
```https://moonriver.api.onfinality.io/public```
| 40 req/sec | + | POKT Network |
```https://moonriver-mainnet.gateway.pokt.network/v1/lb/62a74fdb123e6f003963642f```
| 25 req/sec | + | UnitedBloc |
```https://moonriver.unitedbloc.com```
| 32 req/sec | === "WSS" - | Provider | RPC URL | - |:----------:|:---------------------------------------------------:| - | Blast |
```wss://moonriver.public.blastapi.io```
| - | Dwellir |
```wss://moonriver-rpc.dwellir.com```
| - | UnitedBloc |
```wss://moonriver.unitedbloc.com```
| + | Provider | RPC URL | Limits | + |:----------:|:------------------------------------------------------------:|:----------:| + | Blast |
```wss://moonriver.public.blastapi.io```
| 80 req/sec | + | Dwellir |
```wss://moonriver-rpc.dwellir.com```
| 20 req/sec | + | OnFinality |
```wss://moonriver.api.onfinality.io/public-ws
``` | 40 req/sec | + | UnitedBloc |
```wss://moonriver.unitedbloc.com```
| 32 req/sec | diff --git a/.snippets/text/builders/interoperability/xcm/calculate-multilocation-derivative-account.md b/.snippets/text/builders/interoperability/xcm/calculate-multilocation-derivative-account.md index ddde5db01..c749e0296 100644 --- a/.snippets/text/builders/interoperability/xcm/calculate-multilocation-derivative-account.md +++ b/.snippets/text/builders/interoperability/xcm/calculate-multilocation-derivative-account.md @@ -1,4 +1,4 @@ -Copy the account of your existing or newly created account on the [Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/accounts){target=\_blank}. You're going to need it to calculate the corresponding Computed Origin account, which is a special type of account that’s keyless (the private key is unknown). Transactions from a Computed Origin account can be initiated only via valid XCM instructions from the corresponding account on the relay chain. In other words, you are the only one who can initiate transactions on your Computed Origin account, and if you lose access to your Moonbase relay account, you’ll also lose access to your Computed Origin account. +Copy the account of your existing or newly created account on the [Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/accounts){target=\_blank}. You're going to need it to calculate the corresponding Computed Origin account, which is a special type of account that’s keyless (the private key is unknown). Transactions from a Computed Origin account can be initiated only via valid XCM instructions from the corresponding account on the relay chain. In other words, you are the only one who can initiate transactions on your Computed Origin account, and if you lose access to your Moonbase relay account, you’ll also lose access to your Computed Origin account. To generate the Computed Origin account, first clone the [xcm-tools](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} repo. Run `yarn` to install the necessary packages, and then run: diff --git a/builders/.pages b/builders/.pages index 13d06fa05..c3fddb1db 100644 --- a/builders/.pages +++ b/builders/.pages @@ -4,6 +4,7 @@ nav: - index.md - get-started - build + - json-rpc - pallets-precompiles - interoperability - integrations diff --git a/builders/build/.pages b/builders/build/.pages index d960432cc..1a5c047f9 100644 --- a/builders/build/.pages +++ b/builders/build/.pages @@ -1,8 +1,8 @@ -title: Build +title: Development Toolkit hide: false nav: - index.md - 'Canonical Contracts': 'canonical-contracts.md' - eth-api - substrate-api - - 'Moonbeam Custom API': 'moonbeam-custom-api.md' + diff --git a/builders/build/canonical-contracts.md b/builders/build/canonical-contracts.md index 998f391f0..4e26d4604 100644 --- a/builders/build/canonical-contracts.md +++ b/builders/build/canonical-contracts.md @@ -117,30 +117,30 @@ There are a set of precompiled contracts included on Moonbeam, Moonriver, and Mo | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonriver.precompiles.identity}} | === "Moonbase Alpha" - | Contract | Address | - |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| - | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.staking}} | - | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.crowdloan}} | - | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbase.precompiles.erc20}} | - | [Democracy [Disabled]](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/precompiles/pallet-democracy/DemocracyInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.democracy}} | - | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbase.precompiles.xtokens}} | - | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbase.precompiles.relay_encoder}} | - | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v1}} | - | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.author_mapping}} | - | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbase.precompiles.batch}} | - | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbase.precompiles.randomness}} | - | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbase.precompiles.call_permit}} | - | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbase.precompiles.proxy}} | - | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_utils}} | - | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v2}} | - | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_council}} | - | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_tech_committee}} | - | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_treasury}} | - | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbase.precompiles.referenda}} | - | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbase.precompiles.conviction_voting}} | - | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbase.precompiles.preimage}} | - | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_opengov_tech_committee}} | - | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbase.precompiles.registry}} | - | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbase.precompiles.gmp}} | - | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v3}} | - | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbase.precompiles.identity}} | + | Contract | Address | + |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| + | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.staking}} | + | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.crowdloan}} | + | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbase.precompiles.erc20}} | + | Democracy [Removed] | {{networks.moonbase.precompiles.democracy}} | + | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbase.precompiles.xtokens}} | + | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbase.precompiles.relay_encoder}} | + | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v1}} | + | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.author_mapping}} | + | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbase.precompiles.batch}} | + | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbase.precompiles.randomness}} | + | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbase.precompiles.call_permit}} | + | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbase.precompiles.proxy}} | + | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_utils}} | + | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v2}} | + | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_council}} | + | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_tech_committee}} | + | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_treasury}} | + | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbase.precompiles.referenda}} | + | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbase.precompiles.conviction_voting}} | + | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbase.precompiles.preimage}} | + | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_opengov_tech_committee}} | + | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbase.precompiles.registry}} | + | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbase.precompiles.gmp}} | + | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v3}} | + | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbase.precompiles.identity}} | diff --git a/builders/build/eth-api/.pages b/builders/build/eth-api/.pages index aec45c423..2252f9ba0 100644 --- a/builders/build/eth-api/.pages +++ b/builders/build/eth-api/.pages @@ -1,8 +1,6 @@ -title: Ethereum API +title: Ethereum Tools nav: - index.md - libraries - dev-env - verify-contracts - - 'Debug & Trace': 'debug-trace.md' - - 'Events Subscription': 'pubsub.md' diff --git a/builders/build/eth-api/debug-trace.md b/builders/build/eth-api/debug-trace.md deleted file mode 100644 index a98d35af6..000000000 --- a/builders/build/eth-api/debug-trace.md +++ /dev/null @@ -1,140 +0,0 @@ ---- -title: Debug & Trace Transactions -description: Learn how to leverage Geth's Debug and Txpool APIs, and OpenEthereum's Trace module to call non-standard RPC methods on Moonbeam. ---- - -# Debug API & Trace Module - -## Introduction {: #introduction } - -Geth's debug and txpool APIs and OpenEthereum's trace module provide non-standard RPC methods for getting a deeper insight into transaction processing. As part of Moonbeam's goal of providing a seamless Ethereum experience for developers, there is support for some of these non-standard RPC methods. Supporting these RPC methods is an important milestone because many projects, such as [The Graph](https://thegraph.com/){target=\_blank}, rely on them to index blockchain data. - -To view a list of tracing RPC providers, please check out the [Network Endpoints](/builders/get-started/endpoints#tracing-providers){target=\_blank} page. - -This guide will cover the supported RPC methods available on Moonbeam as well as how to invoke the methods using curl commands against a local Moonbase Alpha tracing node. - -## Supported RPC Methods {: #supported-rpc-methods } - -The following RPC methods are available: - - - [`debug_traceTransaction`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtracetransaction){target=\_blank} - - [`debug_traceBlockByNumber`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbynumber){target=\_blank} - - [`debug_traceBlockByHash`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbyhash){target=\_blank} - - [`trace_filter`](https://openethereum.github.io/JSONRPC-trace-module#trace_filter){target=\_blank} - - [`txpool_content`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-content){target=\_blank} - - [`txpool_inspect`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect){target=\_blank} - - [`txpool_status`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-status){target=\_blank} - -## Debug API {: #geth-debug-api } - -The debug RPC implementations follow [Geth's debug API guidelines](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug){target=\_blank}: - - - **[`debug_traceTransaction`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtracetransaction){target=\_blank}** - requires the hash of the transaction to be traced - - **[`debug_traceBlockByNumber`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbynumber){target=\_blank}** - requires the block number of the block to be traced and an additional parameter that sets the tracer to `callTracer` (i.e., `{"tracer": "callTracer"}`) - - **[`debug_traceBlockByHash`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbyhash){target=\_blank}** - requires the hash of the block to be traced and an additional parameter that sets the tracer to `callTracer` (i.e., `{"tracer": "callTracer"}`) - -As *optional* parameters for the supported debug methods, you can provide the following: - - - **disableStorage**(*boolean*) β€” (default: `false`) setting this to `true` disables storage capture - - **disableMemory**(*boolean*) β€” (default: `false`) setting this to `true` disables memory capture - - **disableStack**(*boolean*) β€” (default: `false`) setting this to `true` disables stack capture - -## Txpool API {: #txpool-api } - -The txpool RPC implementations follow [Geth's txpool API guidelines](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool): - - - **[`txpool_content`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-content){target=\_blank}** - no required or optional parameters - - **[`txpool_inspect`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect){target=\_blank}** - no required or optional parameters - - **[`txpool_status`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-status){target=\_blank}** - no required or optional parameters - -## Trace Module {: #trace-module } - -The [`trace_filter`](https://openethereum.github.io/JSONRPC-trace-module#trace_filter){target=\_blank} RPC implementation follows [OpenEthereum's trace module guidelines](https://openethereum.github.io/JSONRPC-trace-module){target=\_blank}. The RPC method requires any of the following *optional* parameters: - - - **fromBlock**(*uint* blockNumber) β€” either block number (`hex`), `earliest`, which is the genesis block, or `latest` (default), which is the best block available. The trace starting block - - **toBlock**(*uint* blockNumber) β€” either block number (`hex`), `earliest`, which is the genesis block, or `latest`, which is the best block available. The trace ending block - - **fromAddress**(*array* addresses) β€” filter transactions from these addresses only. If an empty array is provided, no filtering is done with this field - - **toAddress**(*array* addresses) β€” filter transactions to these addresses only. If an empty array is provided, no filtering is done with this field - - **after**(*uint* offset) β€” default offset is `0`. The trace offset (or starting) number - - **count**(*uint* numberOfTraces) β€” number of traces to display in a batch - -There are a couple default values that you should be aware of: - - - The maximum number of trace entries a single request of `trace_filter` is allowed to return is `500`. A request exceeding this limit will return an error - - Blocks processed by requests are temporarily stored in the cache for `300` seconds, after which they are deleted - -To change the default values, you can add [Additional Flags](/node-operators/networks/tracing-node/#additional-flags){target=\_blank} when spinning up your tracing node. - -## Checking Prerequisites {: #checking-prerequisites } - -For this guide, you will need to have a locally running instance of a Moonbase Alpha tracing node with the `debug`, `txpool`, and `tracing` flags enabled. You can also adapt the instructions for Moonbeam and Moonriver. - -If you haven't already done so, you can follow the guide on [Running a Tracing Node](/node-operators/networks/tracing-node/){target=\_blank}. The RPC HTTP endpoint should be at `{{ networks.development.rpc_url }}`. - -If you have a running node, you should see a similar terminal log: - -![Debug API](/images/builders/build/eth-api/debug-trace/debug-trace-1.webp) - -## Using the Debug API {: #using-the-debug-api } - -Once you have a running tracing node, you can open another tab in your terminal where you can run curl commands and start to call any of the available JSON-RPC methods. For example, for the `debug_traceTransaction` method, you can make the following JSON-RPC request in your terminal (in this case, for the transaction hash `0x04978f83e778d715eb074352091b2159c0689b5ae2da2554e8fe8e609ab463bf`): - -```sh -curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ - '{ - "jsonrpc":"2.0", - "id":1, - "method":"debug_traceTransaction", - "params": ["0x04978f83e778d715eb074352091b2159c0689b5ae2da2554e8fe8e609ab463bf"] - }' -``` - -The node responds with the step-by-step replayed transaction information (the response was cropped as it is quite long): - -![Trace Debug Node Running](/images/builders/build/eth-api/debug-trace/debug-trace-2.webp) - -If you're using the `debug_traceBlockByNumber` or `debug_traceBlockByHash` methods, you will need to add `{"tracer": "callTracer"}` to the `"params"`. The `callTracer` will only return transactions and subcalls. Otherwise, the tracer will attempt to default to `raw`, which is not supported at this time due to the heavy nature of the call. For example, for the `debug_traceBlockByHash` method, you can make the following JSON-RPC request in your terminal (in this case, for the block hash `0x2633b66050c99d80f65fe96de6485fd407b87f0f59b485c33ab8f119e2c6f255`): - -```sh -curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ - '{ - "jsonrpc":"2.0", - "id":1, - "method":"debug_traceBlockByHash", - "params": ["0x2633b66050c99d80f65fe96de6485fd407b87f0f59b485c33ab8f119e2c6f255", {"tracer": "callTracer"}] - }' -``` - -## Using the Tracing Module {: #using-the-tracing-module } - -For the `trace_filter` call, you can make the following JSON-RPC request in your terminal (in this case, the filter is from block 20000 to 25000, only for transactions where the recipient is `0x4E0078423a39EfBC1F8B5104540aC2650a756577`; it will start with a zero offset and provide the first 20 traces): - -```sh -curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ - '{ - "jsonrpc":"2.0", - "id":1, - "method":"trace_filter", "params":[{"fromBlock":"0x4E20","toBlock":"0x5014","toAddress":["0x4E0078423a39EfBC1F8B5104540aC2650a756577"],"after":0,"count":20}] - }' -``` - -The node responds with the trace information corresponding to the filter (the response was cropped as it is quite long). - -![Trace Filter Node Running](/images/builders/build/eth-api/debug-trace/debug-trace-3.webp) - -## Using the Txpool API {: #using-the-txpool-api } - -Since none of the currently supported txpool methods require a parameter, you can adapt the following curl command by changing the method for any of the txpool methods: - -```sh -curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ - '{ - "jsonrpc":"2.0", - "id":1, - "method":"txpool_status", "params":[] - }' -``` - -For this example, the `txpool_status` method will return the number of transactions currently pending or queued. - -![Txpool Request and Response](/images/builders/build/eth-api/debug-trace/debug-trace-4.webp) diff --git a/builders/build/eth-api/dev-env/hardhat.md b/builders/build/eth-api/dev-env/hardhat.md index 7f4a82c0d..6adc204f9 100644 --- a/builders/build/eth-api/dev-env/hardhat.md +++ b/builders/build/eth-api/dev-env/hardhat.md @@ -60,7 +60,7 @@ You will need to create a Hardhat project if you don't already have one. You can 5. A menu will appear, which will allow you to create a new project or use a sample project. For this example, you can choose **Create an empty hardhat.config.js**, which will create a Hardhat configuration file for your project -![Hardhat Create Project](/images/builders/build/eth-api/dev-env/hardhat/hardhat-1.webp) +--8<-- 'code/builders/build/eth-api/dev-env/hardhat/terminal/hardhat-create.md' ## Hardhat Configuration File {: #hardhat-configuration-file } @@ -153,14 +153,21 @@ If you are planning on using any plugins with your project, you'll need to insta For this example, you can install the `hardhat-ethers` plugin and import it into the configuration file. This plugin provides a convenient way to use the [Ethers.js](/builders/build/eth-api/libraries/ethersjs/){target=\_blank} library to interact with the network. ```bash -npm install @nomicfoundation/hardhat-ethers ethers@6 +npm install @nomicfoundation/hardhat-ethers ethers ``` -To import it, you'll add the following `require` statement to the top of the configuration file: +Additionally, you'll need to install the `hardhat-ignition-ethers` plugin to enable deployment of smart contracts with Hardhat Ignition. You can install it with the following command: -```js hl_lines="2" +```sh +npm install --save-dev @nomicfoundation/hardhat-ignition-ethers +``` + +To import both plugins, add the following `require` statements to the top of the Hardhat configuration file: + +```js hl_lines="2 3" /** @type import('hardhat/config').HardhatUserConfig */ require('@nomicfoundation/hardhat-ethers'); +require('@nomicfoundation/hardhat-ignition-ethers'); const privateKey = 'INSERT_PRIVATE_KEY'; @@ -232,7 +239,7 @@ To use the `compile` task, all you have to do is run: npx hardhat compile ``` -![Hardhat Contract Compile](/images/builders/build/eth-api/dev-env/hardhat/hardhat-2.webp) +--8<-- 'code/builders/build/eth-api/dev-env/hardhat/terminal/compile.md' After compilation, an `artifacts` directory is created that holds the bytecode and metadata of the contract, which are `.json` files. It’s a good idea to add this directory to a `.gitignore` file. @@ -240,60 +247,55 @@ If you make changes to the contract after you've compiled it, you can compile it ## Deploy the Contract {: #deploying-the-contract } -To deploy the contract, you'll create a script that uses [Ethers.js](/builders/build/eth-api/libraries/ethersjs){target=\_blank} to deploy the contract, and you'll run the script using the `run` task. +To deploy the contract, you'll use Hardhat Ignition, a declarative framework for deploying smart contracts. Hardhat Ignition is designed to make it easy to manage recurring tasks surrounding smart contract deployment and testing. For more information, be sure to check out the [Hardhat Ignition docs](https://hardhat.org/ignition/docs/getting-started#overview){target=\_blank}. -You can create a new directory for the script, and name it `scripts`, and add a new file to it called `deploy.js`: +To set up the proper file structure for your Ignition module, create a folder named `ignition` and a subdirectory called `modules`. Then add a new file to it called `Box.js`. You can take all three of these steps with the following command: ```sh -mkdir scripts && touch scripts/deploy.js +mkdir ignition ignition/modules && touch ignition/modules/Box.js ``` -Next, you need to write your deployment script. Because you'll be running it with Hardhat and you've already imported Ethers into your `hardhat.config.js` file, you don't need to import any libraries directly in the script. If you were to run the script with `node` instead, you would need to import Ethers. - -To get started, take the following steps: +Next, you can write your Hardhat Ignition module. To get started, take the following steps: -1. Create a local instance of the contract with the `getContractFactory` method -2. Use the `deploy` method that exists within this instance to instantiate the smart contract -3. Wait for the deployment by using `waitForDeployment` -4. Once deployed, you can fetch the address of the contract using the contract instance. +1. Import the `buildModule` function from the Hardhat Ignition module +2. Export a module using `buildModule` +3. Use the `getAccount` method to select the deployer account +4. Deploy the `Box` contract +5. Return an object from the module. This makes the `Box` contract accessible for interaction in Hardhat tests and scripts ```js -// scripts/deploy.js -async function main() { - // 1. Get the contract to deploy - const Box = await ethers.getContractFactory('Box'); - console.log('Deploying Box...'); - - // 2. Instantiate a new Box smart contract - const box = await Box.deploy(); - - // 3. Wait for the deployment to resolve - await box.waitForDeployment(); +// 1. Import the `buildModule` function from the Hardhat Ignition module +const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules"); + +// 2. Export a module using `buildModule` +module.exports = buildModule("BoxModule", (m) => { + + // 3. Use the `getAccount` method to select the deployer account + const deployer = m.getAccount(0); + + // 4. Deploy the `Box` contract + const box = m.contract("Box", [], { + from: deployer, + }); - // 4. Use the contract instance to get the contract address - console.log('Box deployed to:', box.target); -} + // 5. Return an object from the module + return { box }; +}); -main() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); ``` -To run the script and deploy the `Box.sol` contract, use the following command, which requires you to specify the network name as defined in your `hardhat.config.js` to deploy the contract to: +To run the script and deploy the `Box.sol` contract, use the following command, which requires you to specify the network name as defined in your `hardhat.config.js`. If you don't specify a network, hardhat will deploy the contract to a local hardhat network by default. ```sh -npx hardhat run --network moonbase scripts/deploy.js +npx hardhat ignition deploy ./ignition/modules/Box.js --network moonbase ``` !!! note If you're using another Moonbeam network, make sure that you specify the correct network. The network name needs to match how it's defined in the `hardhat.config.js` file. -After a few seconds, the contract is deployed, and you should see the address in the terminal. +You'll be prompted to confirm the network you wish to deploy to. After a few seconds after you confirm, the contract is deployed, and you'll see the contract address in the terminal. -![Hardhat Contract Deploy](/images/builders/build/eth-api/dev-env/hardhat/hardhat-3.webp) +--8<-- 'code/builders/build/eth-api/dev-env/hardhat/terminal/deploy-moonbase.md' Congratulations, your contract is live! Save the address, as you will use it to interact with this contract instance in the next step. @@ -333,7 +335,7 @@ Next, you can take the following steps, entering one line at a time: The transaction will be signed by your account configured in the `hardhat.config.js` file and broadcasted to the network. The output should look similar to: -![Transaction output](/images/builders/build/eth-api/dev-env/hardhat/hardhat-4.webp) +--8<-- 'code/builders/build/eth-api/dev-env/hardhat/terminal/interact.md' Notice your address labeled `from`, the address of the contract, and the `data` that is being passed. Now, you can retrieve the value by running: @@ -350,7 +352,7 @@ Similarly to the deployment script, you can create a script to interact with you To get started, create a `set-value.js` file in the `scripts` directory: ```sh -touch scripts/set-value.js +mkdir scripts && touch scripts/set-value.js ``` Now paste the following contract into the `set-value.js` file: @@ -388,11 +390,11 @@ npx hardhat run --network moonbase scripts/set-value.js The script should return `2` as the value. -![The terminal output from executing the set-value.js script.](/images/builders/build/eth-api/dev-env/hardhat/hardhat-5-new.webp) +--8<-- 'code/builders/build/eth-api/dev-env/hardhat/terminal/run.md' ## Hardhat Forking {: #hardhat-forking } -You can [fork](https://hardhat.org/hardhat-network/docs/guides/forking-other-networks){target=\_blank} any EVM-compatible chain using Hardhat, including Moonbeam. Forking simulates the live Moonbeam network locally, enabling you to interact with deployed contracts on Moonbeam in a local test environment. Since Hardhat forking is based on an EVM implementation, you can interact with the fork using standard [Ethereum JSON-RPC methods supported by Moonbeam](/learn/core-concepts/rpc-support/){target=\_blank} and [Hardhat](https://hardhat.org/hardhat-network/docs/reference#json-rpc-methods-support){target=\_blank}. +You can [fork](https://hardhat.org/hardhat-network/docs/guides/forking-other-networks){target=\_blank} any EVM-compatible chain using Hardhat, including Moonbeam. Forking simulates the live Moonbeam network locally, enabling you to interact with deployed contracts on Moonbeam in a local test environment. Since Hardhat forking is based on an EVM implementation, you can interact with the fork using standard [Ethereum JSON-RPC methods supported by Moonbeam](/builders/pallets-precompiles/eth-rpc/){target=\_blank} and [Hardhat](https://hardhat.org/hardhat-network/docs/reference#json-rpc-methods-support){target=\_blank}. There are some limitations to be aware of when using Hardhat forking. You cannot interact with any of the Moonbeam precompiled contracts or their functions. Precompiles are a part of the Substrate implementation and therefore cannot be replicated in the simulated EVM environment. This prohibits you from interacting with cross-chain assets on Moonbeam and Substrate-based functionality such as staking and governance. @@ -574,7 +576,7 @@ If you prefer to configure your Hardhat project, you can update your `hardhat.co When you spin up the Hardhat fork, you'll have 20 development accounts that are pre-funded with 10,000 test tokens. The forked instance is available at `http://127.0.0.1:8545/`. The output in your terminal should resemble the following: -![Forking terminal screen](/images/builders/build/eth-api/dev-env/hardhat/hardhat-5.webp) +--8<-- 'code/builders/build/eth-api/dev-env/hardhat/terminal/private-keys.md' To verify you have forked the network, you can query the latest block number: diff --git a/builders/build/eth-api/dev-env/openzeppelin/contracts.md b/builders/build/eth-api/dev-env/openzeppelin/contracts.md index 1ece95dbf..7070b593f 100644 --- a/builders/build/eth-api/dev-env/openzeppelin/contracts.md +++ b/builders/build/eth-api/dev-env/openzeppelin/contracts.md @@ -53,7 +53,7 @@ All the code of the contracts was obtained using OpenZeppelin [Contract Wizard]( ### Checking Prerequisites {: #checking-prerequisites } -The steps described in this section assume you have [MetaMask](https://metamask.io/){target=\_blank} installed and connected to the Moonbase Alpha TestNet. If you're adapting this guide for Moonbeam or Moonriver, make sure you're connected to the correct network. Contract deployment is done using the [Remix IDE](https://remix.ethereum.org/){target=\_blank} via the **Injected Web3** environment. You can find corresponding tutorials in the following links: +The steps described in this section assume you have [MetaMask](https://metamask.io/){target=\_blank} installed and connected to the Moonbase Alpha TestNet. If you're adapting this guide for Moonbeam or Moonriver, make sure you're connected to the correct network. Contract deployment is done using the [Remix IDE](https://remix.ethereum.org/){target=\_blank} via the **Injected Provider** environment. You can find corresponding tutorials in the following links: - [Interacting with Moonbeam using MetaMask](/tokens/connect/metamask/){target=\_blank} - [Interacting with Moonbeam using Remix](/builders/build/eth-api/dev-env/remix/){target=\_blank} @@ -74,25 +74,12 @@ The first step is to go to [Remix](https://remix.ethereum.org/) and take the fol 3. Write your smart contract using the file editor. For this example, the following code was used: ```solidity -pragma solidity ^0.8.0; - -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; - -contract MyToken is ERC20, Ownable { - constructor() ERC20("MyToken", "MTK") { - _mint(msg.sender, 1000 * 10 ** decimals()); - } - - function mint(address to, uint256 amount) public onlyOwner { - _mint(to, amount); - } -} +--8<-- 'code/builders/build/eth-api/dev-env/openzeppelin/ERC20.sol' ``` -This ERC-20 token smart contract was extracted from the [Contract Wizard](#openzeppelin-contract-wizard), setting a premint of `1000` tokens and activating the `Mintable` feature. +This ERC-20 token smart contract was extracted from the [Contract Wizard](#openzeppelin-contract-wizard), setting a premint of `1000` tokens and activating the `Mintable` and `Permit` features. -![Getting Started with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-1.webp) +![Getting Started with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-2.webp) Once your smart contract is written, you can compile it by taking the following steps: @@ -100,17 +87,17 @@ Once your smart contract is written, you can compile it by taking the following 2. Click on the compile button 3. Alternatively, you can check the **Auto compile** feature -![Compile ERC-20 Contract with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-2.webp) +![Compile ERC-20 Contract with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-3.webp) With the contract compiled, you are ready to deploy it taking the following steps: 1. Head to the **Deploy & Run Transactions** tab - 2. Change the environment to **Injected Web3**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet + 2. Change the environment to **Injected Provider**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet 3. Select the proper contract to deploy. In this example, it is the `MyToken` contract inside the `ERC20.sol` file - 4. If everything is ready, click on the **Deploy** button. Review the transaction information in MetaMask and confirm it + 4. Enter the address of the initial owner and click on the **Deploy** button. Review the transaction information in MetaMask and confirm it 5. After a few seconds, the transaction should get confirmed, and you should see your contract under **Deployed Contracts** -![Deploy ERC-20 Contract with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-3.webp) +![Deploy ERC-20 Contract with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-4.webp) And that is it! You've deployed an ERC-20 token contract using OpenZeppelin's contracts and libraries. Next, you can interact with your token contract via Remix, or add it to MetaMask. @@ -130,40 +117,7 @@ As with the [ERC-20 contract](#deploying-an-erc-20-token), the first step is to Next, you'll need to write the smart contract and compile it. For this example, the following code is used: ```solidity -pragma solidity ^0.8.0; - -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; -import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; - -contract MyToken is ERC721, ERC721Enumerable, ERC721Burnable, Ownable { - constructor() ERC721("MyToken", "MTK") {} - - function safeMint(address to, uint256 tokenId) public onlyOwner { - _safeMint(to, tokenId); - } - - function _baseURI() internal pure override returns (string memory) { - return "Test"; - } - - function _beforeTokenTransfer(address from, address to, uint256 tokenId) - internal - override(ERC721, ERC721Enumerable) - { - super._beforeTokenTransfer(from, to, tokenId); - } - - function supportsInterface(bytes4 interfaceId) - public - view - override(ERC721, ERC721Enumerable) - returns (bool) - { - return super.supportsInterface(interfaceId); - } -} +--8<-- 'code/builders/build/eth-api/dev-env/openzeppelin/ERC721.sol' ``` This ERC-721 token smart contract was extracted from the [Contract Wizard](#openzeppelin-contract-wizard), setting the `Base URI` as `Test` and activating the `Mintable`, `Burnable`, and `Enumerable` features. @@ -171,12 +125,12 @@ This ERC-721 token smart contract was extracted from the [Contract Wizard](#open With the contract compiled, next you will need to: 1. Head to the **Deploy & Run Transactions** tab - 2. Change the environment to **Injected Web3**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet + 2. Change the environment to **Injected Provider**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet 3. Select the proper contract to deploy. In this example, it is the `MyToken` contract inside the `ERC721.sol` file - 4. If everything is ready, click on the **Deploy** button. Review the transaction information in MetaMask and confirm it + 4. Enter the address of the initial owner and click on the **Deploy** button. Review the transaction information in MetaMask and confirm it 5. After a few seconds, the transaction should get confirmed, and you should see your contract under **Deployed Contracts** -![Deploy ERC-721 Contract with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-4.webp) +![Deploy ERC-721 Contract with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-5.webp) And that is it! You've deployed an ERC-721 token contract using OpenZeppelin's contracts and libraries. Next, you can interact with your token contract via Remix, or add it to MetaMask. @@ -195,38 +149,7 @@ The first step is to go to [Remix](https://remix.ethereum.org/){target=\_blank} As shown for the [ERC-20 token](#deploying-an-erc-20-token), you'll need to write the smart contract and compile it. For this example, the following code is used: ```solidity -pragma solidity ^0.8.0; - -import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts/security/Pausable.sol"; - -contract MyToken is ERC1155, Ownable, Pausable { - constructor() ERC1155("Test") { - _mint(msg.sender, 0, 1000 * 10 ** 18, ""); - _mint(msg.sender, 1, 1, ""); - } - - function setURI(string memory newuri) public onlyOwner { - _setURI(newuri); - } - - function pause() public onlyOwner { - _pause(); - } - - function unpause() public onlyOwner { - _unpause(); - } - - function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) - internal - whenNotPaused - override - { - super._beforeTokenTransfer(operator, from, to, ids, amounts, data); - } -} +--8<-- 'code/builders/build/eth-api/dev-env/openzeppelin/ERC1155.sol' ``` This ERC-1155 token smart contract was extracted from the [Contract Wizard](#openzeppelin-contract-wizard), setting no `Base URI` and activating `Pausable` feature. The constructor function was modified to include the minting of both a fungible and a non-fungible token. @@ -234,12 +157,12 @@ This ERC-1155 token smart contract was extracted from the [Contract Wizard](#ope With the contract compiled, next you will need to: 1. Head to the **Deploy & Run Transactions** tab - 2. Change the environment to **Injected Web3**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet + 2. Change the environment to **Injected Provider**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet 3. Select the proper contract to deploy. In this example, it is the `MyToken` contract inside the `ERC1155.sol` file - 4. If everything is ready, click on the **Deploy** button. Review the transaction information in MetaMask and confirm it + 4. Enter the address of the initial owner and click on the **Deploy** button. Review the transaction information in MetaMask and confirm it 5. After a few seconds, the transaction should get confirmed, and you should see your contract under **Deployed Contracts** -![Deploy ERC-1155 Contract with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-5.webp) +![Deploy ERC-1155 Contract with Remix](/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-6.webp) And that is it! You've deployed an ERC-1155 token contract using OpenZeppelin's contracts and libraries. Next, you can interact with your token contract via Remix. diff --git a/builders/build/eth-api/pubsub.md b/builders/build/eth-api/pubsub.md deleted file mode 100644 index d3ff44f6c..000000000 --- a/builders/build/eth-api/pubsub.md +++ /dev/null @@ -1,118 +0,0 @@ ---- -title: Subscribe to Ethereum-style Events on Moonbeam -description: Use Ethereum-like publish-subscribe functionality to subscribe to specific events on Moonbeam's Ethereum-compatible chain. ---- - -# Subscribe to Events - -## Introduction {: #introduction } - -Moonbeam supports event subscriptions for Ethereum-style events. This allows you to wait for events and handle them accordingly instead of polling for them. - -It works by subscribing to particular events, and for each subscription, an ID is returned. For each event that matches the subscription, a notification with relevant data is sent together with the subscription ID. - -In this guide, you will learn how to subscribe to event logs, incoming pending transactions, and incoming block headers on Moonbase Alpha. This guide can also be adapted for Moonbeam or Moonriver. - -## Checking Prerequisites {: #checking-prerequisites } - -The examples in this guide are based on an Ubuntu 22.04 environment. You will also need the following: - -- MetaMask installed and [connected to Moonbase Alpha](/tokens/connect/metamask/){target=\_blank} -- An account with funds. - --8<-- 'text/_common/faucet/faucet-list-item.md' -- To deploy your own ERC-20 token on Moonbase Alpha. You can do this following [our Remix tutorial](/builders/build/eth-api/dev-env/remix/){target=\_blank}, while first pointing MetaMask to Moonbase Alpha - ---8<-- 'text/_common/install-nodejs.md' - -As of writing this guide, the versions used were 16.15.1 and 8.11.0, respectively. You will also need to install the Web3 package by executing: - -```bash -npm install --save web3 -``` - -To verify the installed version of Web3, you can use the `ls` command: - -```bash -npm ls web3 -``` - -As of writing this guide, the version used was 4.3.0. - -## Subscribe to Event Logs {: #subscribing-to-event-logs-in-moonbase-alpha } - -Any contract that follows the ERC-20 token standard emits an event related to a transfer of tokens, that is, `event Transfer(address indexed from, address indexed to, uint256 value)`. For this example, you will subscribe to the logs of such events. Using the Web3.js library, you need the following piece of code: - -```js ---8<-- 'code/builders/build/eth-api/pubsub/subscribe-to-event-logs.js' -``` - -Note that you are connecting to the WebSocket endpoint of Moonbase Alpha. You're using the `web3.eth.subscribe(β€˜logs’, options [, callback])` method to subscribe to the logs, filtered by the given options. In this case, the options are the contract’s address where the events are emitted from and the topics used to describe the event. More information about topics can be found in the [Understanding event logs on the Ethereum blockchain](https://medium.com/mycrypto/understanding-event-logs-on-the-ethereum-blockchain-f4ae7ba50378){target=\_blank} Medium post. If you do not provide any topics, you subscribe to all events emitted by the contract. In order to only filter the `Transfer` event, you need to include the signature of the event, calculated as: - -```js -EventSignature = keccak256(Transfer(address,address,uint256)) -``` - -The result of the calculation is shown in the previous code snippet. You'll return to filtering by topics later on. The rest of the code handles the callback function. Once you execute this code, you'll get a subscription ID, and the terminal will wait for any event through that subscription: - -![Subscription ID](/images/builders/build/eth-api/pubsub/pubsub-1.webp) - -Next, an ERC-20 token transfer will be sent with the following parameters: - - - **From address** - `0x44236223aB4291b93EEd10E4B511B37a398DEE55` - - **To address** - `0x8841701Dba3639B254D9CEe712E49D188A1e941e` - - **Value (tokens)** - `1000000000000000000` - that is 1 with 18 zeros - -After you send the transaction, you'll see the event logs emitted by the transaction in your terminal: - -![Log of the transfer event](/images/builders/build/eth-api/pubsub/pubsub-2.webp) - -The target event sends two pieces of indexed information: the `from` and `to` addresses (in that order), which are treated like topics. The other piece of data shared by the event is the number of tokens, which is not indexed. Therefore, there are a total of three topics (the maximum is four), which correspond to the opcode LOG3: - -![Description of LOG3](/images/builders/build/eth-api/pubsub/pubsub-3.webp) - -Consequently, the topics returned by the logs contain the `from` and `to` addresses. Ethereum addresses are 40 hex characters long (1 hex character is 4 bits, hence 160 bits, or H160 format). Thus, the extra 24 zeros are needed to fill the gap to H256, which is 64 hex characters long. - -Unindexed data is returned in the `data` field of the logs, but this is encoded in bytes32/hex. To decode it, you can use, for example, this [Web3 Type Converter tool](https://web3-type-converter.onbrn.com/){target=\_blank} and verify that the `data` is 1 (plus 18 zeros). - -If the event returns multiple unindexed values, they will be appended one after the other in the same order the event emits them. Therefore, each value is then obtained by deconstructing data into separate 32-byte (or 64-hex-character-long) pieces. - -### Use Wildcards and Conditional Formatting {: #using-wildcards-and-conditional-formatting } - -Using the same example as in the previous section, let's subscribe to the events of the token contract with the following code: - -```js ---8<-- 'code/builders/build/eth-api/pubsub/use-wildcards.js' -``` - -Here, by using the wildcard `null` in place for the event signature, you'll filter to listen to all events emitted by the contract that you subscribed to. But with this configuration, you can also use a second input field (`topic_1`) to define a filter by address, as mentioned before. In the case of this subscription, you are notifying that you want to only receive events where `topic_1` is one of the addresses you are providing. Note that the addresses need to be in H256 format. For example, the address `0x44236223aB4291b93EEd10E4B511B37a398DEE55` needs to be entered as `0x00000000000000000000000044236223aB4291b93EEd10E4B511B37a398DEE55`. As before, the output of this subscription will display the event signature in `topic_0` to tell you which event was emitted by the contract. - -![Conditional Subscription](/images/builders/build/eth-api/pubsub/pubsub-4.webp) - -As shown, after you provided the two addresses with conditional formatting, you should have received two logs with the same subscription ID. Events emitted by transactions from different addresses will not throw any logs to this subscription. - -This example showed how you could subscribe to just the event logs of a specific contract, but the Web3.js library provides other subscription types that will be covered in the following sections. - -## Subscribe to Incoming Pending Transactions {: #subscribe-to-incoming-pending-transactions } - -In order to subscribe to pending transactions, you can use the `web3.eth.subscribe(β€˜pendingTransactions’, [, callback])` method, implementing the same callback function to check for the response. This is much simpler than the previous example, and it returns the transaction hash of the pending transactions. - -![Subscribe pending transactions response](/images/builders/build/eth-api/pubsub/pubsub-5.webp) - -You can verify that this transaction hash is the same as that shown in MetaMask (or Remix). - -## Subscribe to Incoming Block Headers {: #subscribe-to-incoming-block-headers } - -Another type available under the Web3.js library is to subscribe to new block headers. To do so, you can use the `web3.eth.subscribe('newBlockHeaders' [, callback])` method, implementing the same callback function to check for the response. This subscription provides incoming block headers and can be used to track changes in the blockchain. - -![Subscribe to block headers response](/images/builders/build/eth-api/pubsub/pubsub-6.webp) - -Note that only one block header is shown in the image. These messages are displayed for every block produced, so they can fill up the terminal quite quickly. - -## Check If a Node Is Synchronized with the Network {: #check-if-a-node-is-synchronized-with-the-network } - -With pub/sub, it is also possible to check whether a particular node you are subscribed to is currently synchronizing with the network. For that, we can leverage the [`web3.eth.subscribe(β€˜syncing' [, callback])`](https://web3js.readthedocs.io/en/v1.2.11/web3-eth-subscribe.html#subscribe-syncing){target=\_blank} method, implementing the same callback function to check for the response. This subscription will either return a boolean when `syncing` is false or an object describing the syncing progress when `syncing` is true, as seen below. - -![Subscribe to syncing response](/images/builders/build/eth-api/pubsub/pubsub-7.webp) - -!!! note - The pub/sub implementation in [Frontier](https://github.com/polkadot-evm/frontier){target=\_blank} is still in active development. This current version allows users to subscribe to specific event types, but there may still be some limitations. diff --git a/builders/build/index.md b/builders/build/index.md index 065381249..e82efa8f3 100644 --- a/builders/build/index.md +++ b/builders/build/index.md @@ -1,7 +1,7 @@ --- title: Guides for Building on Moonbeam description: Guides for learning how to interact with the Ethereum & Substrate APIs to deploy, verify, and interact with contracts, and build DApps on Moonbeam. -dropdown_description: Development libraries, tools, and APIs +dropdown_description: Libraries, tools, and contracts template: subsection-index-page.html hide: - toc diff --git a/builders/build/moonbeam-custom-api.md b/builders/build/moonbeam-custom-api.md deleted file mode 100644 index aac7e18bc..000000000 --- a/builders/build/moonbeam-custom-api.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: Moonbeam-specific RPC Methods -description: This page contains information on Moonbeam custom API endpoints (JSON-RPC methods specific to Moonbeam). ---- - -# Moonbeam Custom API - -## Finality RPC Endpoints {: #finality-rpc-endpoints } - -Moonbeam node has added support for two custom JSON-RPC endpoints, `moon_isBlockFinalized` and `moon_isTxFinalized`, that are useful for checking whether an on-chain event is finalized. The information on these two endpoints are as follows: - -=== "moon_isBlockFinalized" - | Variable | Value | - |:-----------:|:------------------------------------------------------------------------------------------------------------------------:| - | Endpoint | `moon_isBlockFinalized` | - | Description | Check for the finality of the block given by its block hash | - | Parameters | `block_hash`: **STRING** The hash of the block, accepts either Substrate-style or Ethereum-style block hash as its input | - | Returns | `result`: **BOOLEAN** Returns `true` if the block is finalized, `false` if the block is not finalized or not found | - -=== "moon_isTxFinalized" - | Variable | Value | - |:-----------:|:------------------------------------------------------------------------------------------------------------:| - | Endpoint | `moon_isTxFinalized` | - | Description | Check for the finality of the transaction given by its EVM tx hash | - | Parameters | `tx_hash`: **STRING** The EVM tx hash of the transaction | - | Returns | `result`: **BOOLEAN** Returns `true` if the tx is finalized; `false` if the tx is not finalized or not found | - -You can try out these endpoints with the following curl examples. These examples query the public RPC endpoint of Moonbase Alpha, but they can be modified to use with Moonbeam and Moonriver by changing the URL of the RPC endpoint to use your own endpoint and API key which you can get from one of the supported [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. - -=== "moon_isBlockFinalized" - - ```bash - curl -H "Content-Type: application/json" -X POST --data '[ - { - "jsonrpc": "2.0", - "id": "1", - "method": "moon_isBlockFinalized", - "params": ["INSERT_BLOCK_HASH"] - } - ]' - {{ networks.moonbase.rpc_url }} - ``` - -=== "moon_isTxFinalized" - - ```bash - curl -H "Content-Type: application/json" -X POST --data '[ - { - "jsonrpc": "2.0", - "id": "1", - "method": "moon_isTxFinalized", - "params": ["INSERT_TX_HASH"] - } - ]' - {{ networks.moonbase.rpc_url }} - ``` diff --git a/builders/build/substrate-api/.pages b/builders/build/substrate-api/.pages index 8442cb892..8705c45a2 100644 --- a/builders/build/substrate-api/.pages +++ b/builders/build/substrate-api/.pages @@ -1,4 +1,4 @@ -title: Substrate API +title: Substrate Tools nav: - index.md - 'Overview': 'overview.md' diff --git a/builders/build/substrate-api/py-substrate-interface.md b/builders/build/substrate-api/py-substrate-interface.md index 27053f5c8..406c6b294 100644 --- a/builders/build/substrate-api/py-substrate-interface.md +++ b/builders/build/substrate-api/py-substrate-interface.md @@ -392,7 +392,7 @@ You can sign transaction payloads or any arbitrary data using a keypair object t You can also make custom RPC requests with the [`rpc_request`](https://polkascan.github.io/py-substrate-interface/#substrateinterface.SubstrateInterface.rpc_request){target=\_blank} method. -This is particularly useful for interacting with Moonbeam's [Ethereum JSON-RPC](/learn/core-concepts/rpc-support/){target=\_blank} endpoints or Moonbeam's [custom RPC](/builders/build/moonbeam-custom-api/){target=\_blank} endpoints. +This is particularly useful for interacting with Moonbeam's [Ethereum JSON-RPC](/builders/pallets-precompiles/eth-rpc/){target=\_blank} endpoints or Moonbeam's [custom RPC](/builders/pallets-precompiles/moonbeam-custom-api/){target=\_blank} endpoints. The [Consensus and Finality page](/learn/core-concepts/consensus-finality/#checking-tx-finality-with-substrate-libraries){target=\_blank} has examples for using the custom RPC calls through Python Substrate Interface to check the finality of a transaction given its transaction hash. diff --git a/builders/get-started/.pages b/builders/get-started/.pages index ae8a021b0..0bdabe2e7 100644 --- a/builders/get-started/.pages +++ b/builders/get-started/.pages @@ -2,6 +2,7 @@ title: Get Started nav: - index.md - 'Quick Start': 'quick-start.md' + - 'Create an Account': 'create-account.md' - networks - - 'Network Endpoints': 'endpoints.md' + - 'Network RPC Endpoints': 'endpoints.md' - 'Block Explorers': 'explorers.md' diff --git a/builders/get-started/create-account.md b/builders/get-started/create-account.md new file mode 100644 index 000000000..ef2699037 --- /dev/null +++ b/builders/get-started/create-account.md @@ -0,0 +1,39 @@ +--- +title: Create an Account +description: To begin developing on Moonbeam, you must create an account. This guide will provide you with the information needed to create one to use on Moonbeam. +--- + +# Create an Account + +## Introduction {: #introduction } + +To get started developing on Moonbeam, developers must create an account. The most prevalent approach involves leveraging a wallet application, which facilitates generating and managing cryptographic keys essential for interacting with Moonbeam. + +Moonbeam uses H160 Ethereum-style accounts and ECDSA keys, represented in 20-byte addresses. If you already have an Ethereum account and its private key or mnemonic, you can use your account on Moonbeam. + +This guide will walk you through the step-by-step process of creating an account on Moonbeam. Whether you're new to blockchain technology or an experienced Ethereum user, this guide will provide all the information you need to get started. + +!!! note + This guide does not pertain to a local Moonbeam development node. If you are using a development node, you don't need to worry about creating an account, as the node comes with ten pre-funded accounts for testing purposes. Please refer to the [Getting Started with a Local Moonbeam Development Node](/builders/get-started/networks/moonbeam-dev){target=\_blank} guide for more information. + +## Choose a Wallet {: #choose-a-wallet } + +A wallet is a software or hardware tool that allows you to securely store, manage, and interact with your digital assets, such as tokens or coins. Wallets store your private keys, which are essential for authorizing transactions on the network. + +You can review a list of wallets on the [Moonbeam DApp Directory](https://apps.moonbeam.network/moonbeam/app-dir?cat=wallets){target=\_blank}. + +![View list of wallets on the Moonbeam DApp](/images/builders/get-started/create-account/create-account-1.webp) + +The list of wallets on the dApp is not exhaustive and may only cover some of the available options. You should be able to use any Ethereum-compatible wallet to generate an address and its associated private key. + +You can also check out any of the wallets in the [Connect to Moonbeam](/tokens/connect/){target=\_blank} section of the docs. + +## Use Your Wallet to Create an Account {: #use-your-wallet-to-create-an-account } + +After you've selected a wallet and downloaded it, you'll most likely be prompted to create a new account or import an existing one the first time you open it. You'll want to create a new account. + +Depending on the wallet, when creating an account, you may be prompted to backup and restore a seed phrase, also referred to as a mnemonic or recovery phrase. This phrase is a sequence of generated words that serve as a backup mechanism for private keys. They typically consist of 12 to 24 words randomly selected from a predefined list. Seed phrases are used to derive private keys deterministically, meaning that the same sequence of words will always generate the same set of private keys. They are crucial for recovering access to a cryptocurrency wallet in case of loss or device failure. **Make sure you save the phrase in a safe place; if you lose access to this phrase, you'll lose access to any funds you hold in your account.** + +After saving your seed phrase, you can start developing on Moonbeam. Many wallets offer the option to export the private key linked to your account. By doing so, you can utilize your private key instead of the seed phrase during development. However, taking adequate precautions to securely store your private key or seed phrase while developing is essential. + +And that's it! Before sending your first transaction on a Moonbeam-based network, ensure you have the necessary [network configurations for your chosen network](/builders/get-started/networks/){target=\_blank} and an [RPC endpoint](/builders/get-started/endpoints){target=\_blank} for the network. Once you have these items, you'll be able to follow along with tutorials like the [How to use Ethers.js](/builders/build/eth-api/libraries/ethersjs){target=\_blank} or the [How to use Web3.js](/builders/build/eth-api/libraries/web3js){target=\_blank} to send a transaction. diff --git a/builders/get-started/endpoints.md b/builders/get-started/endpoints.md index 69cfd14f4..f5ef8fa31 100644 --- a/builders/get-started/endpoints.md +++ b/builders/get-started/endpoints.md @@ -158,7 +158,7 @@ To get started, head to the [Ankr Protocol](https://www.ankr.com/protocol/){targ ## Tracing RPC Endpoint Providers {: #tracing-providers } -Tracing RPC endpoints allow you to access non-standard RPC methods, such as those that belong to Geth's `debug` and `txpool` APIs and OpenEthereum's `trace` module. To see a list of the supported non-standard RPC methods on Moonbeam for debugging and tracing, please refer to the [Debug API & Trace Module](/builders/build/eth-api/debug-trace){target=\_blank} guide. +Tracing RPC endpoints allow you to access non-standard RPC methods, such as those that belong to Geth's `debug` and `txpool` APIs and OpenEthereum's `trace` module. To see a list of the supported non-standard RPC methods on Moonbeam for debugging and tracing, please refer to the [Debug API & Trace Module](/builders/json-rpc/debug-trace){target=\_blank} guide. The following providers provide tracing RPC endpoints: diff --git a/builders/get-started/networks/.pages b/builders/get-started/networks/.pages index 52f3438d7..88a52d825 100644 --- a/builders/get-started/networks/.pages +++ b/builders/get-started/networks/.pages @@ -1,7 +1,7 @@ title: Networks nav: - index.md - - 'Moonbeam Dev Node': 'moonbeam-dev.md' + - 'Local Moonbeam Dev Node': 'moonbeam-dev.md' - 'Moonbase Alpha': 'moonbase.md' - 'Moonriver': 'moonriver.md' - - 'Moonbeam': 'moonbeam.md' \ No newline at end of file + - 'Moonbeam': 'moonbeam.md' diff --git a/builders/get-started/networks/moonbeam-dev.md b/builders/get-started/networks/moonbeam-dev.md index b9018fb14..1f06aa478 100644 --- a/builders/get-started/networks/moonbeam-dev.md +++ b/builders/get-started/networks/moonbeam-dev.md @@ -288,7 +288,7 @@ For a Moonbeam development node, you can use any of the following block explorer You can also gain access to some non-standard RPC methods by running a tracing node, which allows developers to inspect and debug transactions during runtime. Tracing nodes use a different Docker image than a standard Moonbeam development node. -To learn how to run a Moonbeam development tracing node, check out the [Run a Tracing Node](/node-operators/networks/tracing-node){target=\_blank} guide, and be sure to switch to the **Moonbeam Development Node** tab throughout the instructions. Then, to access the non-standard RPC methods with your tracing node, check out the [Debug & Trace](/builders/build/eth-api/debug-trace){target=\_blank} guide. +To learn how to run a Moonbeam development tracing node, check out the [Run a Tracing Node](/node-operators/networks/tracing-node){target=\_blank} guide, and be sure to switch to the **Moonbeam Development Node** tab throughout the instructions. Then, to access the non-standard RPC methods with your tracing node, check out the [Debug & Trace](/builders/json-rpc/debug-trace){target=\_blank} guide. ## Purge a Development Node {: #purging-your-node } diff --git a/builders/interoperability/xcm/core-concepts/weights-fees.md b/builders/interoperability/xcm/core-concepts/weights-fees.md index 299d032b8..5b99a3a1c 100644 --- a/builders/interoperability/xcm/core-concepts/weights-fees.md +++ b/builders/interoperability/xcm/core-concepts/weights-fees.md @@ -236,7 +236,7 @@ For each XCM instruction, the weight units are converted to balance units as par | Moonbeam | Moonriver | Moonbase Alpha | |:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| -| [{{ networks.moonbeam.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonbeam.spec_version}}/runtime/moonbeam/src/lib.rs#L141){target=\_blank} | [{{ networks.moonriver.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonriver.spec_version}}/runtime/moonriver/src/lib.rs#L142){target=\_blank} | [{{ networks.moonbase.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonbase.spec_version}}/runtime/moonbase/src/lib.rs#L148){target=\_blank} | +| [{{ networks.moonbeam.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonbeam.spec_version}}/runtime/moonbeam/src/lib.rs#L141){target=\_blank} | [{{ networks.moonriver.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonriver.spec_version}}/runtime/moonriver/src/lib.rs#L142){target=\_blank} | [{{ networks.moonbase.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonbase.spec_version}}/runtime/moonbase/src/lib.rs#L144){target=\_blank} | This means that on Moonbeam, for example, the formula to calculate the cost of one XCM instruction in the reserve asset is as follows: diff --git a/builders/interoperability/xcm/remote-execution/remote-evm-calls.md b/builders/interoperability/xcm/remote-execution/remote-evm-calls.md index 43c4b1abe..5c2c00c97 100644 --- a/builders/interoperability/xcm/remote-execution/remote-evm-calls.md +++ b/builders/interoperability/xcm/remote-execution/remote-evm-calls.md @@ -49,7 +49,7 @@ The last difference is in terms of the gas limit. Ethereum uses a gas-metered sy The configuration of the XCM queue suggests that XCM messages should be executable within `20,000,000,000` weight units (that is, `0.02` seconds of block execution time). Suppose the XCM message can't be executed due to the lack of execution time in a given block, and the weight requirement is over `20,000,000,000`. In that case, the XCM message will be marked as `overweight` and will only be executable through democracy. -The `20,000,000,000` weight limit per XCM message constrains the gas limit available for remote EVM calls through XCM. For all Moonbeam-based networks, there is a ratio of [`25,000` units of gas per unit of weight](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/runtime/moonbase/src/lib.rs#L406){target=\_blank} ([`WEIGHT_REF_TIME_PER_SECOND`](https://paritytech.github.io/substrate/master/frame_support/weights/constants/constant.WEIGHT_REF_TIME_PER_SECOND.html){target=\_blank} / [`GAS_PER_SECOND`](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/runtime/moonbase/src/lib.rs#402){target=\_blank}). Considering that you need some of the XCM message weight to execute the XCM instructions themselves. Therefore, a remote EVM call might have around `18,000,000,000` weight left, which is `720,000` gas units. Consequently, the maximum gas limit you can provide for a remote EVM call is around `720,000` gas units. Note that this might change in the future. +The `20,000,000,000` weight limit per XCM message constrains the gas limit available for remote EVM calls through XCM. For all Moonbeam-based networks, there is a ratio of [`25,000` units of gas per unit of weight](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/runtime/moonbase/src/lib.rs#L402){target=\_blank} ([`WEIGHT_REF_TIME_PER_SECOND`](https://paritytech.github.io/substrate/master/frame_support/weights/constants/constant.WEIGHT_REF_TIME_PER_SECOND.html){target=\_blank} / [`GAS_PER_SECOND`](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/runtime/moonbase/src/lib.rs#398){target=\_blank}). Considering that you need some of the XCM message weight to execute the XCM instructions themselves. Therefore, a remote EVM call might have around `18,000,000,000` weight left, which is `720,000` gas units. Consequently, the maximum gas limit you can provide for a remote EVM call is around `720,000` gas units. Note that this might change in the future. In summary, these are the main differences between regular and remote EVM calls: @@ -119,7 +119,7 @@ The process for building and performing the remote execution can be summarized a To be able to send the call from the relay chain, you need the following: -- An [account](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/accounts){target=\_blank} on the relay chain with funds (UNIT) to pay for the transaction fees. You can acquire some xcUNIT by swapping for DEV tokens (Moonbase Alpha's native token) on [Moonbeam-Swap](https://moonbeam-swap.netlify.app){target=\_blank}, a demo Uniswap-V2 clone on Moonbase Alpha, and then [send them to the relay chain](/builders/interoperability/xcm/xc20/send-xc20s/xtokens-pallet/){target_blank}. Additionally, you can [contact us on Discord](https://discord.gg/PfpUATX){target=\_blank} to get some UNIT tokens directly +- An [account](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/accounts){target=\_blank} on the relay chain with funds (UNIT) to pay for the transaction fees. You can acquire some xcUNIT by swapping for DEV tokens (Moonbase Alpha's native token) on [Moonbeam-Swap](https://moonbeam-swap.netlify.app){target=\_blank}, a demo Uniswap-V2 clone on Moonbase Alpha, and then [send them to the relay chain](/builders/interoperability/xcm/xc20/send-xc20s/xtokens-pallet/){target_blank}. Additionally, you can [contact us on Discord](https://discord.gg/PfpUATX){target=\_blank} to get some UNIT tokens directly - The address of your Computed Origin account. Please refer to the [Computed Origin](/builders/interoperability/xcm/remote-execution/computed-origins){target=\_blank} guide to learn how to calculate your Computed Origin address - To fund your Computed Origin account. The account must have enough DEV tokens (or GLMR/MOVR for Moonbeam/Moonriver) to cover the cost of the XCM execution of the remote EVM call. Note that this is the account from which the remote EVM call will be dispatched (the `msg.sender`). Consequently, the account must satisfy whatever conditions are required for the EVM call to be executed correctly. For example, hold any relevant ERC-20 token if you are doing an ERC-20 transfer @@ -283,9 +283,9 @@ Now that you have the values for each of the parameters, you can write the scrip ``` !!! note - You can view an example of the output of the above script on [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/extrinsics/decode/0x630003000100a10f030c00040000010403000f0000c16ff28623130000010403000f0000c16ff2862300060103004775e87a5d02007901260001785d02000000000000000000000000000000000000000000000000000000000000a72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8000000000000000000000000000000000000000000000000000000000000000010d09de08a00){target=\_blank} using the following encoded call data: `0x630003000100a10f030c00040000010403000f0000c16ff28623130000010403000f0000c16ff2862300060103004775e87a5d02007901260001785d02000000000000000000000000000000000000000000000000000000000000a72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8000000000000000000000000000000000000000000000000000000000000000010d09de08a00`. + You can view an example of the output of the above script on [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/extrinsics/decode/0x630003000100a10f030c00040000010403000f0000c16ff28623130000010403000f0000c16ff2862300060103004775e87a5d02007901260001785d02000000000000000000000000000000000000000000000000000000000000a72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8000000000000000000000000000000000000000000000000000000000000000010d09de08a00){target=\_blank} using the following encoded call data: `0x630003000100a10f030c00040000010403000f0000c16ff28623130000010403000f0000c16ff2862300060103004775e87a5d02007901260001785d02000000000000000000000000000000000000000000000000000000000000a72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8000000000000000000000000000000000000000000000000000000000000000010d09de08a00`. -Once the transaction is processed, you can check the relevant extrinsics and events in the [relay chain](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/explorer/query/0x2a0e40a2e5261e792190826ce338ed513fe44dec16dd416a12f547d358773f98){target=\_blank} and [Moonbase Alpha](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer/query/0x7570d6fa34b9dccd8b8839c2986260034eafef732bbc09f8ae5f857c28765145){target=\_blank}. +Once the transaction is processed, you can check the relevant extrinsics and events in the [relay chain](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/explorer/query/0x2a0e40a2e5261e792190826ce338ed513fe44dec16dd416a12f547d358773f98){target=\_blank} and [Moonbase Alpha](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer/query/0x7570d6fa34b9dccd8b8839c2986260034eafef732bbc09f8ae5f857c28765145){target=\_blank}. In the relay chain, the extrinsic is `xcmPallet.send`, and the associated event is `xcmPallet.Sent` (among others related to the fee). In Moonbase Alpha, the XCM execution happens within the `parachainSystem.setValidationData` extrinsic, and there are multiple associated events that can be highlighted: diff --git a/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet.md b/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet.md index e93a3bfae..342ceb7ae 100644 --- a/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet.md +++ b/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet.md @@ -157,7 +157,7 @@ The XCM Transactor Pallet provides the following extrinsics (functions): === "Parameters" - `dest` - the XCM versioned multilocation for a chain in the ecosystem where the XCM message is being sent to (the target chain) - - `feePayer` - the address that will pay for the remote XCM execution in the corresponding [XC-20 token](/builders/interoperability/xcm/xc20/overview/){target=\_blank} + - `feePayer` - (optional) the address that will pay for the remote XCM execution in the corresponding [XC-20 token](/builders/interoperability/xcm/xc20/overview/){target=\_blank}. If you don't specify the `feePayer`, the XCM execution fees will be paid by the Sovereign account on the destination chain - `fee` - the asset to be used for fees. This contains the `currency` and the `feeAmount`: - `currency` - defines how you are specifying the token to use to pay for the fees, which can be either of the following: - `AsCurrencyId` - the currency ID of the asset to use for the fees. The currency ID can be either: diff --git a/builders/interoperability/xcm/xc-registration/xc-integration.md b/builders/interoperability/xcm/xc-registration/xc-integration.md index cf0486523..5972b1810 100644 --- a/builders/interoperability/xcm/xc-registration/xc-integration.md +++ b/builders/interoperability/xcm/xc-registration/xc-integration.md @@ -64,7 +64,7 @@ There are also some [snapshots for the Alphanet ecosystem relay chain](https://w You can calculate the Sovereign account information using [a script from the xcm-tools repository](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank}. To run the script, you must provide the parachain ID and the name of the associated relay chain. -You can find the parachain IDs that have already been used on the [relay chain's Polkadot.js Apps page](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/parachains){target=\_blank}. +You can find the parachain IDs that have already been used on the [relay chain's Polkadot.js Apps page](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/parachains){target=\_blank}. The accepted values for the relay chain are `polkadot` (default), `kusama`, and `moonbase`. @@ -187,7 +187,7 @@ Running the following command will provide the encoded calldata to accept an ope ```bash yarn hrmp-manipulator --target-para-id YOUR_PARACHAIN_ID \ --parachain-ws-provider wss://wss.api.moonbase.moonbeam.network \ - --relay-ws-provider wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network \ + --relay-ws-provider wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network \ --hrmp-action accept ``` @@ -235,7 +235,7 @@ Running the following command will provide the encoded calldata to create the HR ```bash yarn hrmp-manipulator --target-para-id YOUR_PARACHAIN_ID \ --parachain-ws-provider wss://wss.api.moonbase.moonbeam.network \ - --relay-ws-provider wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network \ + --relay-ws-provider wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network \ --max-capacity 1000 --max-message-size 102400 \ --hrmp-action open ``` diff --git a/builders/json-rpc/.pages b/builders/json-rpc/.pages new file mode 100644 index 000000000..fae80d7e1 --- /dev/null +++ b/builders/json-rpc/.pages @@ -0,0 +1,8 @@ +title: JSON-RPC APIs +hide: false +nav: + - index.md + - 'Standard Ethereum': 'eth-rpc.md' + - 'Non-standard Ethereum: Tracing': 'debug-trace.md' + - 'Non-standard Ethereum: Pubsub': 'pubsub.md' + - 'Custom Moonbeam': 'moonbeam-custom-api.md' diff --git a/builders/json-rpc/debug-trace.md b/builders/json-rpc/debug-trace.md new file mode 100644 index 000000000..fd2ced1a4 --- /dev/null +++ b/builders/json-rpc/debug-trace.md @@ -0,0 +1,353 @@ +--- +title: Debug & Trace Transactions +description: Check out the non-standard JSON-RPC methods included in Geth's Debug and Txpool APIs and OpenEthereum's Trace module, which are supported on Moonbeam. +--- + +# Debug API & Trace Module + +## Introduction {: #introduction } + +Geth's [debug](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug){target=\_blank} and [txpool](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool){target=\_blank} APIs and OpenEthereum's [trace](https://openethereum.github.io/JSONRPC-trace-module){target=\_blank} module provide non-standard RPC methods for deeper insight into transaction processing. Some of these non-standard RPC methods are supported as part of Moonbeam's goal of providing a seamless Ethereum experience for developers. Supporting these RPC methods is an essential milestone because many projects like [The Graph](https://thegraph.com/){target=\_blank} rely on them to index blockchain data. + +This guide will cover the supported RPC methods available on Moonbeam and how to invoke them using curl commands against a tracing node with the debug, txpool, and tracing flags enabled. You can access a tracing node in one of two ways: through a supported tracing RPC provider or by spinning up a tracing node of your own. + +To view a list of tracing RPC providers, please check out the [Network Endpoints](/builders/get-started/endpoints#tracing-providers){target=\_blank} page. + +If you wish to set up your own tracing node, you can follow the [Running a Tracing Node](/node-operators/networks/tracing-node/){target=\_blank} guide. The RPC HTTP endpoint of your tracing node should be at `{{ networks.development.rpc_url }}` and your node should display similar logs to the following: + +--8<-- 'code/builders/json-rpc/debug-trace/terminal/start-up-logs.md' + +## Supported Debug and Trace JSON-RPC Methods {: #supported-methods } + +???+ function "debug_traceTransaction" + + This method attempts to replay a transaction in the same manner as it was executed on the network. Refer to [Geth's documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtracetransaction){target=\_blank} for more information. + + === "Parameters" + + - `transaction_hash` *string* - the hash of the transaction to be traced + - `tracer_config` *string* - (optional) a JSON object for configuring the tracer that contains the following field: + - `tracer` *string* - sets the type of tracer + + If no `tracer_config` is provided, the opcode logger will be the default tracer. The opcode logger provides the following additional fields: + + - `opcode_config` *string* - (optional) a JSON object for configuring the opcode logger: + - `disableStorage` *boolean* β€” (optional, default: `false`) setting this to `true` disables storage capture + - `disableMemory` *boolean* β€” (optional, default: `false`) setting this to `true` disables memory capture + - `disableStack` *boolean* β€” (optional, default: `false`) setting this to `true` disables stack capture + + === "Returns" + + If you supplied a `tracer_config`, the `result` object contains the following fields: + + - `type` - the type of the call + - `from` - the address the transaction is sent from + - `to` - the address the transaction is directed to + - `value` - the integer of the value sent with this transaction + - `gas` - the integer of the gas provided for the transaction execution + - `gasUsed` - the integer of the gas used + - `input` - the data given at the time of input + - `output` - the data which is returned as an output + - `error` - the type of error, if any + - `revertReason` - the type solidity revert reason, if any + - `calls` - a list of sub-calls, if any + +
+ If you used the default opcode logger, the `result` object contains the following fields: + + - `gas`- the integer of the gas provided for the transaction execution + - `returnValue` - the output produced by the execution of the transaction + - `structLogs` - an array of [objects containing a detailed log of each opcode](https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers#struct-opcode-logger){target=\_blank} executed during the transaction + - `failed` - a boolean indicating whether the transaction execution failed or succeeded + + === "Example" + + Using the `tracer_config`: + + ```bash + curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ + '{ + "jsonrpc":"2.0", + "id": 1, + "method": "debug_traceTransaction", + "params": ["INSERT_TRANSACTION_HASH", {"tracer": "callTracer"}] + }' + ``` + +
+ Using the default opcode logger: + + ```bash + curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ + '{ + "jsonrpc":"2.0", + "id": 1, + "method": "debug_traceTransaction", + "params": ["INSERT_TRANSACTION_HASH"] + }' + ``` + +???+ function "debug_traceBlockByNumber" + + This method attempts to replay a block in the same manner as it was executed on the network. Refer to [Geth's documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbynumber){target=\_blank} for more information. + + === "Parameters" + + - `block_number` *string* - the block number of the block to be traced + - `tracer_config` *string* - a JSON object for configuring the tracer that contains the following field: + - `tracer` *string* - sets the type of tracer. This must be set to `callTracer`, which only returns transactions and sub-calls. Otherwise, the tracer will attempt to default to the opcode logger, which is not supported at this time due to the heavy nature of the call + + === "Returns" + + The `result` array contains objects with the following fields: + + - `type` - the type of the call + - `from` - the address the transaction is sent from + - `to` - the address the transaction is directed to + - `value` - the integer of the value sent with this transaction + - `gas` - the integer of the gas provided for the transaction execution + - `gasUsed` - the integer of the gas used + - `input` - the data given at the time of input + - `output` - the data which is returned as an output + - `error` - the type of error, if any + - `revertReason` - the type solidity revert reason, if any + - `calls` - a list of sub-calls, if any + + === "Example" + + ```bash + curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ + '{ + "jsonrpc": "2.0", + "id": 1, + "method": "debug_traceBlockByNumber", + "params": ["INSERT_BLOCK_NUMBER", {"tracer": "callTracer"}] + }' + ``` + +???+ function "debug_traceBlockByHash" + + This method attempts to replay a block in the same manner as it was executed on the network. Refer to [Geth's documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbyhash){target=\_blank} for more information. + + === "Parameters" + + - `block_hash` *string* - the block hash of the block to be traced + - `tracer_config` *string* - a JSON object for configuring the tracer that contains the following field: + - `tracer` *string* - sets the type of tracer. This must be set to `callTracer`, which only returns transactions and sub-calls. Otherwise, the tracer will attempt to default to the opcode logger, which is not supported at this time due to the heavy nature of the call + + === "Returns" + + The `result` array contains objects with the following fields: + + - `type` - the type of the call + - `from` - the address the transaction is sent from + - `to` - the address the transaction is directed to + - `value` - the integer of the value sent with this transaction + - `gas` - the integer of the gas provided for the transaction execution + - `gasUsed` - the integer of the gas used + - `input` - the data given at the time of input + - `output` - the data which is returned as an output + - `error` - the type of error, if any + - `revertReason` - the type solidity revert reason, if any + - `calls` - a list of sub-calls + + === "Example" + + ```bash + curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ + '{ + "jsonrpc": "2.0", + "id": 1, + "method": "debug_traceBlockByHash", + "params": ["INSERT_BLOCK_HASH", {"tracer": "callTracer"}] + }' + ``` + +???+ function "trace_filter" + + This method returns matching traces for the given filters. Refer to [Open Ethereum's documentation](https://openethereum.github.io/JSONRPC-trace-module#trace_filter){target=\_blank} for more information. + + === "Parameters" + + - `fromBlock` *string* β€” (optional) either block number (hex), `earliest`, which is the genesis block, or `latest` (default), which is the best block available. The trace starting block + - `toBlock` *string* β€” (optional) either block number (hex), `earliest`, which is the genesis block, or `latest`, which is the best block available. The trace-ending block + - `fromAddress` *array* β€” (optional) filter transactions from these addresses only. If an empty array is provided, no filtering is done with this field + - `toAddress` *array* β€” (optional) filter transactions to these addresses only. If an empty array is provided, no filtering is done with this field + - `after` *uint* β€” (optional) the default offset is `0`. The trace offset (or starting) number + - `count` *uint* β€” (optional) number of traces to display in a batch + + There are a couple of default values that you should be aware of: + + - The maximum number of trace entries a single request of `trace_filter` is allowed to return is `500`. A request exceeding this limit will return an error + - Blocks processed by requests are temporarily stored in the cache for `300` seconds, after which they are deleted + + You can configure [additional flags](/node-operators/networks/tracing-node/#additional-flags){target=\_blank} when spinning up your tracing node to change the default values. + + === "Returns" + + The `result` array contains an array of objects for the block traces. All objects will contain the following fields: + + - `blockHash`- the hash of the block where this transaction was in + - `blockNumber` - the block number where this transaction was in + - `subtraces` - the traces of contract calls made by the transaction + - `traceAddress` - the list of addresses where the call was executed, the address of the parents, and the order of the current sub-call + - `transactionHash` - the hash of the transaction + - `transactionPosition` - the transaction position + - `type` - the value of the method, such as `call` or `create` + +
+ If the `type` of the transaction is a `call`, these additional fields will exist: + + - `action` - an object containing the call information: + - `from` - the address of the sender + - `callType` - the type of method, such as `call` and `delegatecall` + - `gas` - the gas provided by the sender, encoded as hexadecimal + - `input` - the data sent along with the transaction + - `to` - the address of the receiver + - `value` - the integer of the value sent with this transaction, encoded as hexadecimal + - `result` - an object containing the result of the transaction + - `gasUsed`- the amount of gas used by this specific transaction alone + - `output`- the value returned by the contract call, and it only contains the actual value sent by the return method. If the return method was not executed, the output is empty bytes + + If the `type` of the transaction is a `create`, these additional fields will exist: + + - `action` - an object containing information on the contract creation: + - `from` - the address of the sender + - `creationMethod` - the creation method, such as `create` + - `gas` - the gas provided by the sender, encoded as hexadecimal + - `init` - the initialization code of the contract + - `value` - the integer of the value sent with this transaction, encoded as hexadecimal + - `result` - an object containing the result of the transaction + - `address` - the address of the contract + - `code` - the bytecode of the contract + - `gasUsed`- the amount of gas used by this specific transaction alone + + === "Example" + + This example starts with a zero offset and provides the first 20 traces: + + ```sh + curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ + '{ + "jsonrpc": "2.0", + "id": 1, + "method": "trace_filter", "params": + [{ + "fromBlock": "INSERT_FROM_BLOCK", + "toBlock": "INSERT_TO_BLOCK", + "toAddress": ["INSERT_ADDRESS_TO_FILTER"], + "after": 0, + "count": 20 + }] + }' + ``` + +???+ function "txpool_content" + + Returns the details for all currently pending transactions waiting to be included in the next block(s) and all queued transactions for future execution. Refer to [Geth's documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-content){target=\_blank} for more information. + + === "Parameters" + + None + + === "Returns" + + The `result` object contains the following fields: + + - `pending` - an object containing the pending transaction details, which maps an address to a batch of scheduled transactions + - `address` - the address initiating a transaction, which maps the addresses' associating nonces with their transactions + - `nonce` - the nonce of the sending address + - `blockHash` - the hash of the block where this transaction was included. For pending transactions, this is an empty 32-byte string in hexadecimal format + - `blockNumber` - the block number where this transaction was added encoded as a hexadecimal. For pending transactions, this is `null` + - `from` - the address of the sender + - `gas` - the total amount of gas units used in the transaction + - `gasPrice` - the total amount in Wei the sender is willing to pay for the transaction + - `maxFeePerGas` - the maximum amount of gas willing to be paid for the transaction + - `maxPriorityFeePerGas` - the maximum amount of gas to be included as a tip to the miner + - `hash` - the hash of the transaction + - `input` - the encoded transaction input data + - `nonce` - the number of transactions the sender has sent till now + - `to` - the address of the receiver. `null` when it's a contract creation transaction + - `transactionIndex` - an integer of the transactions index position in the block encoded as a hexadecimal format. For pending transactions, this is `null` + - `value` - the value transferred in Wei encoded as a hexadecimal format + - `queued` - an object containing the queued transaction details, which maps an address to a batch of scheduled transactions + - `address` - the address initiating a transaction, which maps the addresses' associating nonces with their transactions + - `nonce` - the nonce of the sending address + - `blockHash` - the hash of the block where this transaction was included. For queued transactions, this is an empty 32-byte string in hexadecimal format + - `blockNumber` - the block number where this transaction was added encoded as a hexadecimal. For queued transactions, this is `null` + - `from` - the address of the sender + - `gas` - the total amount of gas units used in the transaction + - `gasPrice` - the total amount in wei the sender is willing to pay for the transaction + - `maxFeePerGas` - the maximum amount of gas willing to be paid for the transaction + - `maxPriorityFeePerGas` - the maximum amount of gas to be included as a tip to the miner + - `hash` - the hash of the transaction + - `input` - the encoded transaction input data + - `nonce` - the number of transactions the sender has sent till now + - `to` - the address of the receiver. `null` when it's a contract creation transaction + - `transactionIndex` - an integer of the transactions index position in the block encoded as a hexadecimal format. For queued transactions, this is `null` + - `value` - the value transferred in Wei encoded as a hexadecimal format + + === "Example" + + ```sh + curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ + '{ + "jsonrpc": "2.0", + "id": 1, + "method": "txpool_content", "params":[] + }' + ``` + +???+ function "txpool_inspect" + + Returns a summary for all currently pending transactions waiting to be included in the next block(s) and all queued transactions for future execution. Refer to [Geth's documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect){target=\_blank} for more information. + + === "Parameters" + + None + + === "Returns" + + The `result` object contains the following fields: + + - `pending` - an object containing the pending transaction summary strings, which maps an address to a batch of scheduled transactions + - `address` - the address initiating a transaction, which maps the addresses' associating nonces with their transaction summary strings + - `queued` - an object containing the queued transaction summary strings, which maps an address to a batch of scheduled transactions + - `address` - the address initiating a transaction, which maps the addresses' associating nonces with their transaction summary strings + + === "Example" + + ```sh + curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ + '{ + "jsonrpc": "2.0", + "id": 1, + "method" "txpool_inspect", "params":[] + }' + ``` + +???+ function "txpool_status" + + Returns the total number of transactions currently pending transactions waiting to be included in the next block(s) and all queued transactions for future execution. Refer to [Geth's documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-status){target=\_blank} for more information. + + === "Parameters" + + None + + === "Returns" + + The `result` object contains the following fields: + + - `pending` - a counter representing the number of pending transactions + - `queued` - a counter representing the number of queued transactions + + === "Example" + + ```sh + curl {{ networks.development.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ + '{ + "jsonrpc": "2.0", + "id": 1, + "method": "txpool_status", "params":[] + }' + ``` diff --git a/builders/json-rpc/eth-rpc.md b/builders/json-rpc/eth-rpc.md new file mode 100644 index 000000000..bca813ae8 --- /dev/null +++ b/builders/json-rpc/eth-rpc.md @@ -0,0 +1,64 @@ +--- +title: Standard Ethereum JSON-RPC Methods +description: Explore a comprehensive list of standard Ethereum JSON-RPC methods that can be used to interface with Moonbeam nodes programmatically. +--- + +# Supported Ethereum RPC Methods + +## Introduction {: #introduction } + +The Moonbeam team has collaborated closely with [Parity](https://www.parity.io/){target=\_blank} on developing [Frontier](/learn/platform/technology/#frontier){target=\_blank}, an Ethereum compatibility layer for Substrate-based chains. This layer enables developers to run unmodified Ethereum dApps on Moonbeam seamlessly. + +Nevertheless, not all Ethereum JSON-RPC methods are supported; some of those supported return default values (those related to Ethereum's PoW consensus mechanism in particular). This guide provides a comprehensive list of supported Ethereum JSON-RPC methods on Moonbeam. Developers can quickly reference this list to understand the available functionality for interfacing with Moonbeam's Ethereum-compatible blockchain. + +## Standard Ethereum JSON-RPC Methods {: #basic-rpc-methods } + +The basic JSON-RPC methods from the Ethereum API supported by Moonbeam are: + +- **[eth_protocolVersion](https://eth.wiki/json-rpc/API#eth_protocolversion){target=\_blank}** β€” returns `1` by default +- **[eth_syncing](https://eth.wiki/json-rpc/API#eth_syncing){target=\_blank}** β€” returns an object with data about the sync status or `false` +- **[eth_hashrate](https://eth.wiki/json-rpc/API#eth_hashrate){target=\_blank}** β€” returns `"0x0"` by default +- **[eth_coinbase](https://eth.wiki/json-rpc/API#eth_coinbase){target=\_blank}** β€” returns the latest block author. Not necessarily a finalized block +- **[eth_mining](https://eth.wiki/json-rpc/API#eth_mining){target=\_blank}** β€” returns `false` by default +- **[eth_chainId](https://eth.wiki/json-rpc/API#eth_chainid){target=\_blank}** β€” returns the chain ID used for signing at the current block +- **[eth_gasPrice](https://eth.wiki/json-rpc/API#eth_gasprice){target=\_blank}** β€” returns the base fee per unit of gas used. This is currently the minimum gas price for each network +- **[eth_accounts](https://eth.wiki/json-rpc/API#eth_accounts){target=\_blank}** β€” returns a list of addresses owned by the client +- **[eth_blockNumber](https://eth.wiki/json-rpc/API#eth_blocknumber){target=\_blank}** β€” returns the highest available block number +- **[eth_getBalance](https://eth.wiki/json-rpc/API#eth_getbalance){target=\_blank}** β€” returns the balance of the given address +- **[eth_getStorageAt](https://eth.wiki/json-rpc/API#eth_getstorageat){target=\_blank}** β€” returns the content of the storage at a given address +- **[eth_getBlockByHash](https://eth.wiki/json-rpc/API#eth_getblockbyhash){target=\_blank}** β€” returns information about the block of the given hash, including `baseFeePerGas` on post-London blocks +- **[eth_getBlockByNumber](https://eth.wiki/json-rpc/API#eth_getblockbynumber){target=\_blank}** β€” returns information about the block specified by block number, including `baseFeePerGas` on post-London blocks +- **[eth_getTransactionCount](https://eth.wiki/json-rpc/API#eth_gettransactioncount){target=\_blank}** β€” returns the number of transactions sent from the given address (nonce) +- **[eth_getBlockTransactionCountByHash](https://eth.wiki/json-rpc/API#eth_getblocktransactioncountbyhash){target=\_blank}** β€” returns the number of transactions in a block with a given block hash +- **[eth_getBlockTransactionCountByNumber](https://eth.wiki/json-rpc/API#eth_getblocktransactioncountbynumber){target=\_blank}** β€” returns the number of transactions in a block with a given block number +- **[eth_getUncleCountByBlockHash](https://eth.wiki/json-rpc/API#eth_getunclecountbyblockhash){target=\_blank}** β€” returns `"0x0"` by default +- **[eth_getUncleCountByBlockNumber](https://eth.wiki/json-rpc/API#eth_getunclecountbyblocknumber){target=\_blank}** β€” returns `"0x0"` by default +- **[eth_getCode](https://eth.wiki/json-rpc/API#eth_getcode){target=\_blank}** β€” returns the code at the given address at the given block number +- **[eth_sendTransaction](https://eth.wiki/json-rpc/API#eth_sendtransaction){target=\_blank}** β€” creates a new message call transaction or a contract creation, if the data field contains code. Returns the transaction hash or the zero hash if the transaction is not yet available +- **[eth_sendRawTransaction](https://eth.wiki/json-rpc/API#eth_sendrawtransaction){target=\_blank}** β€” creates a new message call transaction or a contract creation for signed transactions. Returns the transaction hash or the zero hash if the transaction is not yet available +- **[eth_call](https://eth.wiki/json-rpc/API#eth_call){target=\_blank}** β€” executes a new message call immediately without creating a transaction on the blockchain, returning the value of the executed call +- **[eth_estimateGas](https://eth.wiki/json-rpc/API#eth_estimategas){target=\_blank}** β€” returns an estimated amount of gas necessary for a given transaction to succeed. You can optionally specify a `gasPrice` or `maxFeePerGas` and `maxPriorityFeePerGas` +- **[eth_feeHistory](https://docs.alchemy.com/alchemy/apis/ethereum/eth-feehistory){target=\_blank}** β€” returns `baseFeePerGas`, `gasUsedRatio`, `oldestBlock`, and `reward` for a specified range of up to 1024 blocks +- **[eth_getTransactionByHash](https://eth.wiki/json-rpc/API#eth_gettransactionbyhash){target=\_blank}** β€” returns the information about a transaction with a given hash. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields +- **[eth_getTransactionByBlockHashAndIndex](https://eth.wiki/json-rpc/API#eth_gettransactionbyblockhashandindex){target=\_blank}** β€” returns information about a transaction at a given block hash and a given index position. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields +- **[eth_getTransactionByBlockNumberAndIndex](https://eth.wiki/json-rpc/API#eth_gettransactionbyblocknumberandindex){target=\_blank}** β€” returns information about a transaction at a given block number and a given index position. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields +- **[eth_getTransactionReceipt](https://eth.wiki/json-rpc/API#eth_gettransactionreceipt){target=\_blank}** β€” returns the transaction receipt of a given transaction hash +- **[eth_getUncleByBlockHashAndIndex](https://eth.wiki/json-rpc/API#eth_getunclebyblockhashandindex){target=\_blank}** β€” returns `null` by default +- **[eth_getUncleByBlockNumberAndIndex](https://eth.wiki/json-rpc/API#eth_getunclebyblocknumberandindex){target=\_blank}** β€” returns `null` by default +- **[eth_getLogs](https://eth.wiki/json-rpc/API#eth_getlogs){target=\_blank}** β€” returns an array of all logs matching a given filter object +- **[eth_getWork](https://eth.wiki/json-rpc/API#eth_getwork){target=\_blank}** β€” returns `["0x0","0x0","0x0"]` by default +- **[eth_submitWork](https://eth.wiki/json-rpc/API#eth_submitwork){target=\_blank}** β€” not supported on Moonbeam +- **[eth_submitHashrate](https://eth.wiki/json-rpc/API#eth_submithashrate){target=\_blank}** β€” not supported on Moonbeam +- **[eth_newFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter){target=\_blank}** β€” creates a filter object based on the input provided. Returns a filter ID +- **[eth_newBlockFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newblockfilter){target=\_blank}** β€” creates a filter in the node to notify when a new block arrives. Returns a filter id +- **[eth_getFilterChanges](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges){target=\_blank}** β€” polling method for filters (see methods above). Returns an array of logs that occurred since the last poll +- **[eth_getFilterLogs](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterlogs){target=\_blank}** β€” returns an array of all the logs matching the filter with a given ID +- **[eth_uninstallFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallfilter){target=\_blank}** β€” uninstall a filter with a given ID. It should be used when polling is no longer needed. Filters timeout when they are not requested using `eth_getFilterChanges` after some time + +## Additional RPC Methods {: #additional-rpc-methods } + +Check out some of the non-standard Ethereum and Moonbeam-specific RPC methods: + +- [Debug and Trace](/builders/json-rpc/debug-trace) +- [Event Subscription](/builders/json-rpc/pubsub) +- [Custom Moonbeam](/builders/json-rpc/moonbeam-custom-api) diff --git a/builders/json-rpc/index.md b/builders/json-rpc/index.md new file mode 100644 index 000000000..fba704d59 --- /dev/null +++ b/builders/json-rpc/index.md @@ -0,0 +1,9 @@ +--- +title: JSON RPC API +description: The JSON-RPC API for Moonbeam provides a set of methods for interacting with a Moonbeam node programmatically over JSON-RPC (Remote Procedure Call). +dropdown_description: Methods you can interact with over JSON-RPC +template: subsection-index-page.html +hide: + - toc + - feedback +--- diff --git a/builders/json-rpc/moonbeam-custom-api.md b/builders/json-rpc/moonbeam-custom-api.md new file mode 100644 index 000000000..45c705b34 --- /dev/null +++ b/builders/json-rpc/moonbeam-custom-api.md @@ -0,0 +1,60 @@ +--- +title: Moonbeam-specific RPC Methods +description: Discover Moonbeam's specialized API endpoints, featuring custom JSON-RPC methods designed exclusively for Moonbeam functionality. +--- + +# Moonbeam Custom API + +## Introduction {: #introduction } + +Moonbeam nodes include support for two custom JSON-RPC endpoints: `moon_isBlockFinalized` and `moon_isTxFinalized`. These endpoints provide valuable functionality for checking the finality of on-chain events. + +To begin exploring Moonbeam's custom JSON-RPC endpoints, you can try out the provided curl examples below. These examples demonstrate how to query the public RPC endpoint of Moonbase Alpha. However, you can easily modify them to use with your own Moonbeam or Moonriver endpoint by changing the URL and API key. If you haven't already, you can obtain your endpoint and API key from one of our supported [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. + +## Supported Custom RPC Methods {: #rpc-methods } + +???+ function "moon_isBlockFinalized" + + Checks for the finality of the block given by its block hash. + + === "Parameters" + + - `block_hash` *string* - the hash of the block, accepts either Substrate-style or Ethereum-style block hash as its input + + === "Returns" + + Returns a boolean: `true` if the block is finalized, `false` if the block is not finalized or not found. + + === "Example" + + ```bash + curl -H "Content-Type: application/json" -X POST --data '{ + "jsonrpc": "2.0", + "id": "1", + "method": "moon_isBlockFinalized", + "params": ["INSERT_BLOCK_HASH"] + }' {{ networks.moonbase.rpc_url }} + ``` + +???+ function "moon_isTxFinalized" + + Checks for the finality of a transaction given its EVM transaction hash. + + === "Parameters" + + - `tx_hash` *string* - the EVM transaction hash of the transaction + + === "Returns" + + Returns a boolean: `true` if the transaction is finalized, `false` if the transaction is not finalized or not found. + + === "Example" + + ```bash + curl -H "Content-Type: application/json" -X POST --data '{ + "jsonrpc": "2.0", + "id": "1", + "method": "moon_isTxFinalized", + "params": ["INSERT_TRANSACTION_HASH"] + }' {{ networks.moonbase.rpc_url }} + ``` diff --git a/builders/json-rpc/pubsub.md b/builders/json-rpc/pubsub.md new file mode 100644 index 000000000..c4243cd2f --- /dev/null +++ b/builders/json-rpc/pubsub.md @@ -0,0 +1,191 @@ +--- +title: Subscribe to Ethereum-style Events on Moonbeam +description: Take a look at the non-standard Ethereum JSON-RPC methods supported on Moonbeam that offer publish-subscribe functionality for specific events. +--- + +# Subscribe to Events + +## Introduction {: #introduction } + +Moonbeam supports event subscriptions for Ethereum-style events, which allows you to wait for events and handle them accordingly instead of polling for them. + +It works by subscribing to particular events; an ID is returned for each subscription. For each event that matches the subscription, a notification with relevant data is sent together with the subscription ID. + +In this guide, you will learn how to subscribe to event logs, incoming pending transactions, and incoming block headers on Moonbase Alpha. This guide can also be adapted for Moonbeam or Moonriver. + +## Supported Pubsub JSON-RPC Methods {: #filter-rpc-methods } + +Please note that the examples in this section require installing [wscat](https://github.com/websockets/wscat){target=\_blank}. + +???+ function "eth_subscribe" + + Creates a subscription for a given subscription name. + + === "Parameters" + + - `subscription_name` *string* - the type of the event to subscribe to. The [supported subscription](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#create-subscriptions#supported-subscriptions){target=\_blank} types are: + - [`newHeads`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#newheads){target=\_blank} β€” triggers a notification each time a new header is appended to the chain + - [`logs`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#logs){target=\_blank} β€” returns logs that are included in new imported blocks and match a given filter criteria + - [`newPendingTransactions`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#newpendingtransactions){target=\_blank} β€” returns the hash for all transactions that are added to the pending state + - [`syncing`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#syncing){target=\_blank} β€” indicates when the node starts or stops synchronizing with the network + + === "Returns" + + The `result` returns the subscription ID. + + === "Example" + + ```bash + wscat -c {{ networks.moonbase.wss_url }} -x ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "eth_subscribe", + "params": ["INSERT_SUBSCRIPTION_NAME"] + }' + ``` + +???+ function "eth_unsubscribe" + + Creates a subscription for a given subscription name. + + === "Parameters" + + - `subscription_id` *string* - the subscription ID + + === "Returns" + + The `result` returns a boolean indicating whether or not the subscription was successfully canceled. + + === "Example" + + ```bash + wscat -c {{ networks.moonbase.wss_url }} -x ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "eth_unsubscribe", + "params": ["INSERT_SUBSCRIPTION_ID"] + }' + ``` + +## Subscribe to Events Using Ethereum Libraries {: #subscribe-to-events } + +This section will show you how to use [Ethereum libraries](/builders/build/eth-api/libraries/){target=\_blank}, like [Web3.js](/builders/build/eth-api/libraries/web3js){target=\_blank}, to programmatically subscribe to events on Moonbeam. + +### Checking Prerequisites {: #checking-prerequisites } + +The examples in this guide are based on an Ubuntu 22.04 environment. You will also need the following: + +- MetaMask installed and [connected to Moonbase Alpha](/tokens/connect/metamask/){target=\_blank} +- An account with funds. + --8<-- 'text/_common/faucet/faucet-list-item.md' +- To deploy your own ERC-20 token on Moonbase Alpha. You can do this following [our Remix tutorial](/builders/build/eth-api/dev-env/remix/){target=\_blank} while first pointing MetaMask to Moonbase Alpha +- Web3.js or the Ethereum library of your choice installed. You can install Web3.js via npm: + + ```bash + npm install web3 + ``` + +### Subscribe to Event Logs {: #subscribing-to-event-logs-in-moonbase-alpha } + +Any contract that follows the ERC-20 token standard emits an event related to a token transfer, that is, `event Transfer(address indexed from, address indexed to, uint256 value)`. In this section, you'll learn how to subscribe to these events using the Web3.js library. + +Use the following code snippet to set up a subscription to listen for token transfer events: + +```js +--8<-- 'code/builders/json-rpc/pubsub/subscribe-to-event-logs.js' +``` + +!!! note + Make sure to replace `'INSERT_CONTRACT_ADDRESS'` with the actual address of the ERC-20 token contract that you should have already deployed (as a [prerequisite](#checking-prerequisites)). + +In the provided code: + +- A subscription is set up using the [`web3.subscribe('logs', options)`](https://docs.web3js.org/libdocs/Web3Eth/#subscribelogs-options){target=\_blank} method to receive logs emitted by the contract, which listens for new data and logs it to the console +- The `topics` array filters logs to include only events with the specified event signature. For this example, logs are filtered using the signature of the `Transfer` event, which can be calculated as follows: + + ```js + EventSignature = keccak256(Transfer(address,address,uint256)) + ``` + + This translates to `0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef`, as seen in the code snippet. + +If you do not provide any topics, you subscribe to all events emitted by the contract. More information about topics can be found in the [Understanding event logs on the Ethereum blockchain](https://medium.com/mycrypto/understanding-event-logs-on-the-ethereum-blockchain-f4ae7ba50378){target=\_blank} Medium post. + +By executing this code, you'll establish a subscription to monitor ERC-20 token transfer events on Moonbeam. The terminal will display a subscription ID indicating a successful setup and await any new events emitted by the contract. + +![Subscription ID](/images/builders/json-rpc/pubsub/pubsub-1.webp) + +#### Understanding Event Logs {: #understanding-event-logs } + +To illustrate the process, assume that an ERC-20 token transfer has been sent with the following parameters: + + - **From address** - `0x44236223aB4291b93EEd10E4B511B37a398DEE55` + - **To address** - `0x8841701Dba3639B254D9CEe712E49D188A1e941e` + - **Value (tokens)** - `1000000000000000000` (1 DEV in Wei) + +The event logs emitted by the transaction are as follows: + +![Log of the transfer event](/images/builders/json-rpc/pubsub/pubsub-2.webp) + +If you look at the `topics` array, there are a total of three topics present (in this order): + +1. The event signature of the `Transfer` event +2. The `from` address +3. The `to` address + +As there are a total of three topics (the maximum is four), this corresponds to the LOG3 opcode: + +![Description of LOG3](/images/builders/json-rpc/pubsub/pubsub-3.webp) + +Indexed topics, such as the `from` and `to` addresses, are typically represented by 256-bit (64 hexadecimal character) values. If necessary, they are padded with zeros to reach the full length. + +Unindexed data, such as the value of tokens transferred, is not included in the `topics` array. Instead, it is returned within the logs' `data` field, encoded in bytes32/hex format. To decode it, you can use, for example, this [Web3 Type Converter tool](https://web3-type-converter.onbrn.com/){target=\_blank} and verify that the `data` is 1 DEV token formatted in Wei. + +If the event returns multiple unindexed values, they will be appended one after the other in the same order the event emits them. Therefore, each value is obtained by deconstructing data into separate 32-byte (or 64-hex-character-long) pieces. + +#### Use Wildcards and Conditional Formatting {: #using-wildcards-and-conditional-formatting } + +Using the same example as in the previous section, you can subscribe to all of the events of the token contract with the following code: + +```js +--8<-- 'code/builders/json-rpc/pubsub/use-wildcards.js' +``` + +Here, by using the wildcard `null` in place of the event signature, you'll filter to listen to all events emitted by the contract you subscribe to. However, with this configuration, you can also use a second input field (`topic_1`) to filter by address. + +In the case of this subscription, you are notifying that you want to only receive events where `topic_1` is one of the addresses you are providing. Note that addresses need to be in H256 format. For example, the address `0x44236223aB4291b93EEd10E4B511B37a398DEE55` needs to be entered as `0x00000000000000000000000044236223aB4291b93EEd10E4B511B37a398DEE55`. + +As before, this subscription's output will display the event signature in `topic_0` to tell you which event the contract emitted. + +![Conditional Subscription](/images/builders/json-rpc/pubsub/pubsub-4.webp) + +As shown, after you provided the two addresses with conditional formatting, you should have received two logs with the same subscription ID. Events emitted by transactions from different addresses will not throw any logs to this subscription. + +This example showed how you could subscribe to just the event logs of a specific contract, but the Web3.js library provides other subscription types that will be covered in the following sections. + +### Subscribe to Incoming Pending Transactions {: #subscribe-to-incoming-pending-transactions } + +To subscribe to pending transactions, you can use the [`web3.eth.subscribe('pendingTransactions')`](https://docs.web3js.org/libdocs/Web3Eth/#subscribependingtransactions){target=\_blank} method, implementing the same callback function to check for the response. The transaction hash of the pending transactions is returned. + +![Subscribe pending transactions response](/images/builders/json-rpc/pubsub/pubsub-5.webp) + +You can try this by sending a transaction and verifying that the transaction hash returned by the subscription is the same one returned by the development tool or wallet you are using. + +### Subscribe to Incoming Block Headers {: #subscribe-to-incoming-block-headers } + +You can also subscribe to new block headers using the [`web3.eth.subscribe('newHeads')`](https://docs.web3js.org/libdocs/Web3Eth/#subscribenewheads){target=\_blank} method, implementing the same callback function to check for the response. This subscription provides incoming block headers and can be used to track changes in the blockchain. + +![Subscribe to block headers response](/images/builders/json-rpc/pubsub/pubsub-6.webp) + +Note that only one block header is shown in the image. These messages are displayed for every block produced so they can quickly fill up the terminal. + +### Check If a Node Is Synchronized with the Network {: #check-if-a-node-is-synchronized-with-the-network } + +With pubsub, checking whether a particular node is currently synchronizing with the network is also possible. You can use the [`web3.eth.subscribe('syncing')`](https://docs.web3js.org/libdocs/Web3Eth/#subscribesyncing){target=\_blank} method, implementing the same callback function to check for the response. This subscription will either return a boolean when `syncing` is false or an object describing the syncing progress when `syncing` is true, as seen below. + +![Subscribe to syncing response](/images/builders/json-rpc/pubsub/pubsub-7.webp) + +!!! note + The pubsub implementation in [Frontier](https://github.com/polkadot-evm/frontier){target=\_blank} is still in active development. This current version allows users to subscribe to specific event types, but there may still be some limitations. diff --git a/builders/pallets-precompiles/.pages b/builders/pallets-precompiles/.pages index 093d74c8a..2510d0910 100644 --- a/builders/pallets-precompiles/.pages +++ b/builders/pallets-precompiles/.pages @@ -1,4 +1,4 @@ -title: Pallets & Precompiles +title: Development Interfaces hide: false nav: - index.md diff --git a/builders/pallets-precompiles/index.md b/builders/pallets-precompiles/index.md index 4d42c1521..f02e2243e 100644 --- a/builders/pallets-precompiles/index.md +++ b/builders/pallets-precompiles/index.md @@ -1,10 +1,9 @@ --- title: Guides for Building on Moonbeam description: Guides for learning how to interact with the Ethereum & Substrate APIs to deploy, verify, and interact with contracts, and build DApps on Moonbeam. -dropdown_description: Access core features via Substrate and Solidity interfaces +dropdown_description: Precompiled Solidity contracts and Substrate interfaces template: subsection-index-page.html hide: - toc - feedback --- - diff --git a/builders/pallets-precompiles/pallets/.pages b/builders/pallets-precompiles/pallets/.pages index 116916bc0..3f535ee73 100644 --- a/builders/pallets-precompiles/pallets/.pages +++ b/builders/pallets-precompiles/pallets/.pages @@ -1,4 +1,4 @@ -title: Pallets +title: Substrate Interfaces nav: - index.md - 'Conviction Voting': 'conviction-voting.md' diff --git a/builders/pallets-precompiles/pallets/index.md b/builders/pallets-precompiles/pallets/index.md index cca8a9ef7..5a68b69f8 100644 --- a/builders/pallets-precompiles/pallets/index.md +++ b/builders/pallets-precompiles/pallets/index.md @@ -1,6 +1,6 @@ --- -title: Pallets -description: Pallets are the building blocks of Substrate-based blockchains, such as Moonbeam. Explore the available pallets on Moonbeam and the functionality they expose. +title: The Substrate Pallets on Moonbeam +description: Substrate-based blockchains like Moonbeam utilize modular components to encapsulate specific functionalities. Explore these modules and their functionalities. template: subsection-index-page.html hide: - toc diff --git a/builders/pallets-precompiles/precompiles/.pages b/builders/pallets-precompiles/precompiles/.pages index d3a393cd0..f3556ceaf 100644 --- a/builders/pallets-precompiles/precompiles/.pages +++ b/builders/pallets-precompiles/precompiles/.pages @@ -1,4 +1,4 @@ -title: Solidity Precompiles +title: Precompiled Contracts nav: - index.md - 'Overview': 'overview.md' diff --git a/builders/pallets-precompiles/precompiles/index.md b/builders/pallets-precompiles/precompiles/index.md index 0d277ca69..87cd424ba 100644 --- a/builders/pallets-precompiles/precompiles/index.md +++ b/builders/pallets-precompiles/precompiles/index.md @@ -1,6 +1,6 @@ --- title: Solidity Precompiles -description: A list of guides for interacting with precompiled contracts on Moonbeam, enabling you to interact with Substrate features using the Ethereum API. +description: Discover the precompiled contracts on Moonbeam, your gateway to effortless interaction with Substrate modules and features using the Ethereum API. template: subsection-index-page.html hide: - toc diff --git a/builders/pallets-precompiles/precompiles/overview.md b/builders/pallets-precompiles/precompiles/overview.md index 614263d41..e5a71d778 100644 --- a/builders/pallets-precompiles/precompiles/overview.md +++ b/builders/pallets-precompiles/precompiles/overview.md @@ -92,30 +92,30 @@ The precompiled contracts are categorized by address and based on the origin net | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonriver.precompiles.identity}} | === "Moonbase Alpha" - | Contract | Address | - |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| - | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.staking}} | - | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.crowdloan}} | - | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbase.precompiles.erc20}} | - | [Democracy [Disabled]](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/precompiles/pallet-democracy/DemocracyInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.democracy}} | - | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbase.precompiles.xtokens}} | - | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbase.precompiles.relay_encoder}} | - | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v1}} | - | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.author_mapping}} | - | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbase.precompiles.batch}} | - | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbase.precompiles.randomness}} | - | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbase.precompiles.call_permit}} | - | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbase.precompiles.proxy}} | - | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_utils}} | - | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v2}} | - | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_council}} | - | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_tech_committee}} | - | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_treasury}} | - | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbase.precompiles.referenda}} | - | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbase.precompiles.conviction_voting}} | - | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbase.precompiles.preimage}} | - | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_opengov_tech_committee}} | - | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbase.precompiles.registry}} | - | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbase.precompiles.gmp}} | - | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v3}} | - | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbase.precompiles.identity}} | + | Contract | Address | + |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| + | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.staking}} | + | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.crowdloan}} | + | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbase.precompiles.erc20}} | + | Democracy [Removed] | {{networks.moonbase.precompiles.democracy}} | + | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbase.precompiles.xtokens}} | + | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbase.precompiles.relay_encoder}} | + | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v1}} | + | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.author_mapping}} | + | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbase.precompiles.batch}} | + | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbase.precompiles.randomness}} | + | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbase.precompiles.call_permit}} | + | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbase.precompiles.proxy}} | + | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_utils}} | + | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v2}} | + | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_council}} | + | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_tech_committee}} | + | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_treasury}} | + | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbase.precompiles.referenda}} | + | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbase.precompiles.conviction_voting}} | + | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbase.precompiles.preimage}} | + | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_opengov_tech_committee}} | + | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbase.precompiles.registry}} | + | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbase.precompiles.gmp}} | + | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v3}} | + | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbase.precompiles.identity}} | diff --git a/images/builders/build/eth-api/debug-trace/debug-trace-1.webp b/images/builders/build/eth-api/debug-trace/debug-trace-1.webp deleted file mode 100644 index e60d0f3ab..000000000 Binary files a/images/builders/build/eth-api/debug-trace/debug-trace-1.webp and /dev/null differ diff --git a/images/builders/build/eth-api/debug-trace/debug-trace-2.webp b/images/builders/build/eth-api/debug-trace/debug-trace-2.webp deleted file mode 100644 index cd969f29f..000000000 Binary files a/images/builders/build/eth-api/debug-trace/debug-trace-2.webp and /dev/null differ diff --git a/images/builders/build/eth-api/debug-trace/debug-trace-3.webp b/images/builders/build/eth-api/debug-trace/debug-trace-3.webp deleted file mode 100644 index 02fd715ec..000000000 Binary files a/images/builders/build/eth-api/debug-trace/debug-trace-3.webp and /dev/null differ diff --git a/images/builders/build/eth-api/debug-trace/debug-trace-4.webp b/images/builders/build/eth-api/debug-trace/debug-trace-4.webp deleted file mode 100644 index cbad421a3..000000000 Binary files a/images/builders/build/eth-api/debug-trace/debug-trace-4.webp and /dev/null differ diff --git a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-1.webp b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-1.webp index 4ffb9693a..3e179edc7 100644 Binary files a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-1.webp and b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-1.webp differ diff --git a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-2.webp b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-2.webp index 00c9c3b82..e7cc0c29e 100644 Binary files a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-2.webp and b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-2.webp differ diff --git a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-3.webp b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-3.webp index 718fc967d..32290492f 100644 Binary files a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-3.webp and b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-3.webp differ diff --git a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-4.webp b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-4.webp index afb7bab09..c4dd18793 100644 Binary files a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-4.webp and b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-4.webp differ diff --git a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-5.webp b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-5.webp index 1349ec9c5..2621f7faa 100644 Binary files a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-5.webp and b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-5.webp differ diff --git a/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-6.webp b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-6.webp new file mode 100644 index 000000000..6d266c942 Binary files /dev/null and b/images/builders/build/eth-api/dev-env/openzeppelin/contracts/oz-contracts-6.webp differ diff --git a/images/builders/get-started/create-account/create-account-1.webp b/images/builders/get-started/create-account/create-account-1.webp new file mode 100644 index 000000000..4c562f27f Binary files /dev/null and b/images/builders/get-started/create-account/create-account-1.webp differ diff --git a/images/builders/build/eth-api/pubsub/pubsub-1.webp b/images/builders/json-rpc/pubsub/pubsub-1.webp similarity index 100% rename from images/builders/build/eth-api/pubsub/pubsub-1.webp rename to images/builders/json-rpc/pubsub/pubsub-1.webp diff --git a/images/builders/build/eth-api/pubsub/pubsub-2.webp b/images/builders/json-rpc/pubsub/pubsub-2.webp similarity index 100% rename from images/builders/build/eth-api/pubsub/pubsub-2.webp rename to images/builders/json-rpc/pubsub/pubsub-2.webp diff --git a/images/builders/build/eth-api/pubsub/pubsub-3.webp b/images/builders/json-rpc/pubsub/pubsub-3.webp similarity index 100% rename from images/builders/build/eth-api/pubsub/pubsub-3.webp rename to images/builders/json-rpc/pubsub/pubsub-3.webp diff --git a/images/builders/build/eth-api/pubsub/pubsub-4.webp b/images/builders/json-rpc/pubsub/pubsub-4.webp similarity index 100% rename from images/builders/build/eth-api/pubsub/pubsub-4.webp rename to images/builders/json-rpc/pubsub/pubsub-4.webp diff --git a/images/builders/build/eth-api/pubsub/pubsub-5.webp b/images/builders/json-rpc/pubsub/pubsub-5.webp similarity index 100% rename from images/builders/build/eth-api/pubsub/pubsub-5.webp rename to images/builders/json-rpc/pubsub/pubsub-5.webp diff --git a/images/builders/build/eth-api/pubsub/pubsub-6.webp b/images/builders/json-rpc/pubsub/pubsub-6.webp similarity index 100% rename from images/builders/build/eth-api/pubsub/pubsub-6.webp rename to images/builders/json-rpc/pubsub/pubsub-6.webp diff --git a/images/builders/build/eth-api/pubsub/pubsub-7.webp b/images/builders/json-rpc/pubsub/pubsub-7.webp similarity index 100% rename from images/builders/build/eth-api/pubsub/pubsub-7.webp rename to images/builders/json-rpc/pubsub/pubsub-7.webp diff --git a/learn/core-concepts/consensus-finality.md b/learn/core-concepts/consensus-finality.md index 9080bf433..4b95b8d86 100644 --- a/learn/core-concepts/consensus-finality.md +++ b/learn/core-concepts/consensus-finality.md @@ -77,9 +77,9 @@ The snippets below follow this strategy to check transaction finality. It uses t Moonbeam has added support for two custom RPC endpoints, `moon_isBlockFinalized` and `moon_isTxFinalized`, that can be used to check whether an on-chain event is finalized. These methods are a bit more straightforward, as you don't need to compare block numbers to ensure your transaction is finalized. -For more information, you can go to the [Finality RPC Endpoints](/builders/build/moonbeam-custom-api#finality-rpc-endpoints){target=\_blank} section of the Moonbeam Custom API page. +For more information, you can go to the [Finality RPC Endpoints](/builders/pallets-precompiles/moonbeam-custom-api#finality-rpc-endpoints){target=\_blank} section of the Moonbeam Custom API page. -You can modify the scripts from the Ethereum RPC section above to use `moon_isBlockFinalized` and `moon_isTxFinalized`. To do this, you can make custom calls to the Substrate JSON-RPC using the `send` method of both [Web3.js](https://web3js.readthedocs.io/){target=\_blank} and [Ethers.js](https://docs.ethers.org/){target=\_blank}. Custom RPC requests are also possible using [Web3.py](https://web3py.readthedocs.io/){target=\_blank} with the `make_request` method. You'll need to pass in the method name and the parameters to the custom request, which you can find on the [Moonbeam Custom API](/builders/build/moonbeam-custom-api/){target=\_blank} page. +You can modify the scripts from the Ethereum RPC section above to use `moon_isBlockFinalized` and `moon_isTxFinalized`. To do this, you can make custom calls to the Substrate JSON-RPC using the `send` method of both [Web3.js](https://web3js.readthedocs.io/){target=\_blank} and [Ethers.js](https://docs.ethers.org/){target=\_blank}. Custom RPC requests are also possible using [Web3.py](https://web3py.readthedocs.io/){target=\_blank} with the `make_request` method. You'll need to pass in the method name and the parameters to the custom request, which you can find on the [Moonbeam Custom API](/builders/pallets-precompiles/moonbeam-custom-api/){target=\_blank} page. ???+ code "moon_isBlockFinalized" diff --git a/learn/core-concepts/rpc-support.md b/learn/core-concepts/rpc-support.md deleted file mode 100644 index a7ddce8ee..000000000 --- a/learn/core-concepts/rpc-support.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: Supported RPC Methods -description: A description of the main differences that Ethereum developers need to understand in terms of the Ethereum RPC support Moonbeam provides. ---- - -# Supported Ethereum RPC Methods - -## Introduction {: #introduction } - -The Moonbeam team has collaborated closely with [Parity](https://www.parity.io/){target=\_blank} on developing [Frontier](/learn/platform/technology/#frontier){target=\_blank}. Frontier is the Ethereum compatibility layer for Substrate-based chains, and it is what allows developers to run unmodified Ethereum DApps. - -Nevertheless, not all of the Ethereum JSON-RPC methods are supported, and some of the supported ones return default values (those related to Ethereum's PoW consensus mechanism in particular). This guide will outline some of these main differences around Ethereum RPC support and what to expect when using Moonbeam for the first time. - -## Basic Ethereum JSON-RPC Methods {: #basic-rpc-methods } - -The basic JSON-RPC methods from the Ethereum API supported by Moonbeam are: - -- **[eth_protocolVersion](https://eth.wiki/json-rpc/API#eth_protocolversion){target=\_blank}** β€” returns `1` by default -- **[eth_syncing](https://eth.wiki/json-rpc/API#eth_syncing){target=\_blank}** β€” returns an object with data about the sync status or `false` -- **[eth_hashrate](https://eth.wiki/json-rpc/API#eth_hashrate){target=\_blank}** β€” returns `"0x0"` by default -- **[eth_coinbase](https://eth.wiki/json-rpc/API#eth_coinbase){target=\_blank}** β€” returns the latest block author. Not necessarily a finalized block -- **[eth_mining](https://eth.wiki/json-rpc/API#eth_mining){target=\_blank}** β€” returns `false` by default -- **[eth_chainId](https://eth.wiki/json-rpc/API#eth_chainid){target=\_blank}** β€” returns the chain ID used for signing at the current block -- **[eth_gasPrice](https://eth.wiki/json-rpc/API#eth_gasprice){target=\_blank}** β€” returns the base fee per unit of gas used. This is currently the minimum gas price for each network -- **[eth_accounts](https://eth.wiki/json-rpc/API#eth_accounts){target=\_blank}** β€” returns a list of addresses owned by the client -- **[eth_blockNumber](https://eth.wiki/json-rpc/API#eth_blocknumber){target=\_blank}** β€” returns the highest available block number -- **[eth_getBalance](https://eth.wiki/json-rpc/API#eth_getbalance){target=\_blank}** β€” returns the balance of the given address -- **[eth_getStorageAt](https://eth.wiki/json-rpc/API#eth_getstorageat){target=\_blank}** β€” returns content of the storage at a given address -- **[eth_getBlockByHash](https://eth.wiki/json-rpc/API#eth_getblockbyhash){target=\_blank}** β€” returns information about the block of the given hash including `baseFeePerGas` on post-London blocks -- **[eth_getBlockByNumber](https://eth.wiki/json-rpc/API#eth_getblockbynumber){target=\_blank}** β€” returns information about the block specified by block number including `baseFeePerGas` on post-London blocks -- **[eth_getTransactionCount](https://eth.wiki/json-rpc/API#eth_gettransactioncount){target=\_blank}** β€” returns the number of transactions sent from the given address (nonce) -- **[eth_getBlockTransactionCountByHash](https://eth.wiki/json-rpc/API#eth_getblocktransactioncountbyhash){target=\_blank}** β€” returns the number of transactions in a block with a given block hash -- **[eth_getBlockTransactionCountByNumber](https://eth.wiki/json-rpc/API#eth_getblocktransactioncountbynumber){target=\_blank}** β€” returns the number of transactions in a block with a given block number -- **[eth_getUncleCountByBlockHash](https://eth.wiki/json-rpc/API#eth_getunclecountbyblockhash){target=\_blank}** β€” returns `"0x0"` by default -- **[eth_getUncleCountByBlockNumber](https://eth.wiki/json-rpc/API#eth_getunclecountbyblocknumber){target=\_blank}** β€” returns `"0x0"` by default -- **[eth_getCode](https://eth.wiki/json-rpc/API#eth_getcode){target=\_blank}** β€” returns the code at given address at given block number -- **[eth_sendTransaction](https://eth.wiki/json-rpc/API#eth_sendtransaction){target=\_blank}** β€” creates new message call transaction or a contract creation, if the data field contains code. Returns the transaction hash, or the zero hash if the transaction is not yet available -- **[eth_sendRawTransaction](https://eth.wiki/json-rpc/API#eth_sendrawtransaction){target=\_blank}** β€” creates new message call transaction or a contract creation for signed transactions. Returns the transaction hash, or the zero hash if the transaction is not yet available -- **[eth_call](https://eth.wiki/json-rpc/API#eth_call){target=\_blank}** β€” executes a new message call immediately without creating a transaction on the block chain, returning the value of the executed call -- **[eth_estimateGas](https://eth.wiki/json-rpc/API#eth_estimategas){target=\_blank}** β€” returns an estimate amount of how much gas is necessary for a given transaction to succeed. You can optionally specify a `gasPrice` or `maxFeePerGas` and `maxPriorityFeePerGas` -- **[eth_feeHistory](https://docs.alchemy.com/alchemy/apis/ethereum/eth-feehistory){target=\_blank}** β€” returns `baseFeePerGas`, `gasUsedRatio`, `oldestBlock`, and `reward` for a specified range of up to 1024 blocks -- **[eth_getTransactionByHash](https://eth.wiki/json-rpc/API#eth_gettransactionbyhash){target=\_blank}** β€” returns the information about a transaction with a given hash. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields -- **[eth_getTransactionByBlockHashAndIndex](https://eth.wiki/json-rpc/API#eth_gettransactionbyblockhashandindex){target=\_blank}** β€” returns information about a transaction at a given block hash, and a given index position. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields -- **[eth_getTransactionByBlockNumberAndIndex](https://eth.wiki/json-rpc/API#eth_gettransactionbyblocknumberandindex){target=\_blank}** β€” returns information about a transaction at a given block number, and a given index position. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields -- **[eth_getTransactionReceipt](https://eth.wiki/json-rpc/API#eth_gettransactionreceipt){target=\_blank}** β€” returns the transaction receipt of a given transaction hash. After London support was added in runtime 1200, a new field named `effectiveGasPrice` has been added to the receipt, specifying the gas price of the transaction -- **[eth_getUncleByBlockHashAndIndex](https://eth.wiki/json-rpc/API#eth_getunclebyblockhashandindex){target=\_blank}** β€” returns `null` by default -- **[eth_getUncleByBlockNumberAndIndex](https://eth.wiki/json-rpc/API#eth_getunclebyblocknumberandindex){target=\_blank}** β€” returns `null` by default -- **[eth_getLogs](https://eth.wiki/json-rpc/API#eth_getlogs){target=\_blank}** β€” returns an array of all logs matching a given filter object -- **[eth_getWork](https://eth.wiki/json-rpc/API#eth_getwork){target=\_blank}** β€” returns `["0x0","0x0","0x0"]` by default -- **[eth_submitWork](https://eth.wiki/json-rpc/API#eth_submitwork){target=\_blank}** β€” not supported on Moonbeam -- **[eth_submitHashrate](https://eth.wiki/json-rpc/API#eth_submithashrate){target=\_blank}** β€” not supported on Moonbeam - -## Filter-related Ethereum JSON-RPC Methods {: #filter-rpc-methods } - -The filter-related JSON-RPC methods from the Ethereum API supported by Moonbeam are: - -- **[eth_newFilter](https://eth.wiki/json-rpc/API#eth_newfilter){target=\_blank}** β€” creates a filter object based on the input provided. Returns a filter ID -- **[eth_newBlockFilter](https://eth.wiki/json-rpc/API#eth_newblockfilter){target=\_blank}** β€” creates a filter in the node to notify when a new block arrives. Returns a filter id -- **[eth_getFilterChanges](https://eth.wiki/json-rpc/API#eth_getfilterchanges){target=\_blank}** β€” polling method for filters (see methods above). Returns an array of logs which occurred since last poll -- **[eth_getFilterLogs](https://eth.wiki/json-rpc/API#eth_getfilterlogs){target=\_blank}** β€” returns an array of all the logs matching the filter with a given ID -- **[eth_uninstallFilter](https://eth.wiki/json-rpc/API#eth_uninstallfilter){target=\_blank}** β€” uninstall a filter with a given ID. Should be used when polling is no longer needed. Filters timeout when they are not requested using `eth_getFilterChanges` after a period of time - -## Event Subscription Ethereum JSON-RPC Methods {: #event-subscription-rpc-methods } - -The [event subscription JSON-RPC methods](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#create-subscriptions){target=\_blank} from the Ethereum API supported by Moonbeam are: - -- **[eth_subscribe](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#create-subscriptions){target=\_blank}** β€” creates a subscription for a given subscription name. If successful, returns the subscription ID -- **[eth_unsubscribe](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#cancel-subscriptions){target=\_blank}** β€” cancels the subscription given by its ID - -### Supported Subscription Parameters {: #supported-subscription } - -The [supported subscriptions](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#create-subscriptions#supported-subscriptions){target=\_blank} are: - -- **[newHeads](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#newheads){target=\_blank}** β€” triggers a notification each time a new header is appended to the chain -- **[logs](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#logs){target=\_blank}** β€” returns logs that are included in new imported blocks, and match a given filter criteria -- **[newPendingTransactions](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#newpendingtransactions){target=\_blank}** β€” returns the hash for all transactions that are added to the pending state -- **[syncing](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#syncing){target=\_blank}** β€” indicates when the node starts or stop synchronizing with the network - -For a dedicated tutorial for these subscriptions, check out the [Events Subscription](/builders/build/eth-api/pubsub/){target=\_blank} guide. - -## Debug and Trace JSON-RPC Methods {: #debug-trace } - -The supported methods from Geth's [debug](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug){target=\_blank} and [txpool](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool){target=\_blank} APIs and OpenEthereum's [trace](https://openethereum.github.io/JSONRPC-trace-module){target=\_blank} module are as follows: - -- **[debug_traceTransaction](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtracetransaction){target=\_blank}** - given a transaction hash, this method attempts to replay a transaction in the exact same manner as it was executed on the network -- **[debug_traceBlockByNumber](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debug_traceblockbynumber){target=\_blank}** - given a block number, this method attempts to replay a block in the exact same manner as it was executed on the network -- **[debug_traceBlockByHash](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debug_traceblockbyhash){target=\_blank}** - given a block hash, this method attempts to replay a block in the exact same manner as it was executed on the network -- **[trace_filter](https://openethereum.github.io/JSONRPC-trace-module#trace_filter){target=\_blank}** - given a filter, this method returns matching traces -- **[txpool_content](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-content){target=\_blank}** - returns the details for all of the transactions that are currently pending, waiting to be included in the next block(s), and queued for future execution -- **[txpool_inspect](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect){target=\_blank}** - returns a summary of all of the transactions that are currently pending, waiting to be included in the next block(s), and queued for future execution -- **[txpool_status](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-status){target=\_blank}** - returns the total number of transactions currently pending, waiting to be included in the next block(s), and queued for future execution - -For a dedicated tutorial for these debug and trace methods, check out the [Debug API & Trace Module](/builders/build/eth-api/debug-trace/){target=\_blank} guide. diff --git a/learn/features/eth-compatibility.md b/learn/features/eth-compatibility.md index f40fb680e..5b0d65963 100644 --- a/learn/features/eth-compatibility.md +++ b/learn/features/eth-compatibility.md @@ -35,9 +35,9 @@ In addition to standard Ethereum RPC methods, Moonbeam supports non-standard Deb Learn more: -- [Supported Ethereum RPC methods](/learn/core-concepts/rpc-support){target=\_blank} -- [Subscribe to events with Ethereum JSON-RPC methods](/builders/build/eth-api/pubsub){target=\_blank} -- [Debug and trace transactions with non-standard RPC methods](/builders/build/eth-api/debug-trace){target=\_blank} +- [Supported Ethereum RPC methods](/builders/json-rpc/eth-rpc){target=\_blank} +- [Subscribe to events with Ethereum JSON-RPC methods](/builders/json-rpc/pubsub){target=\_blank} +- [Debug and trace transactions with non-standard RPC methods](/builders/json-rpc/debug-trace){target=\_blank} ### Ethereum Developer Tools and Libraries {: #ethereum-dev-tools } diff --git a/learn/platform/networks/overview.md b/learn/platform/networks/overview.md index 8d1e51a19..02a78da2d 100644 --- a/learn/platform/networks/overview.md +++ b/learn/platform/networks/overview.md @@ -1,29 +1,29 @@ --- title: Overview of Networks -description: An overview of all of the MainNet and TestNet deployments of Moonbeam, an Ethereum compatible smart contract parachain on Polkadot and Kusama. +description: An overview of all of the MainNet and TestNet deployments of Moonbeam, an Ethereum-compatible smart contract parachain on Polkadot and Kusama. --- # Networks There are multiple long-lived Moonbeam-based networks. Most significantly, there is the Moonbeam deployment on Polkadot and Kusama. -An overview of our parachain deployments are as follows: +An overview of our parachain deployments is as follows: - Moonbeam: deployment on Polkadot (_December 2021_) - Moonriver: deployment on Kusama (_June 2021_) - - Moonbase Alpha: Parachain TestNet for Moonbeam and Moonriver (_September 2020_) - + - Moonbase Alpha: Parachain TestNet for Moonbeam and Moonriver (_September 2020_) + This strategy allows us to de-risk software upgrades to Moonbeam on the Polkadot MainNet while still maintaining a reasonable update velocity. -## Moonbeam {: #moonbeam } +## Moonbeam {: #moonbeam } -The Moonbeam production MainNet is a parachain on Polkadot and has been since December 17th 2021. Moonbeam features the highest levels of security and availability. Code running on the MainNet has generally been vetted through one or more of the other networks listed above. +The Moonbeam production MainNet is a parachain on Polkadot and has been since December 17th, 2021. Moonbeam features the highest levels of security and availability. Code running on the MainNet has generally been vetted through one or more of the other networks listed above. Moonbeam will offer parachain-related functionalities such as [XCMP](https://wiki.polkadot.network/docs/learn-crosschain){target=\_blank} and [SPREE](https://wiki.polkadot.network/docs/learn-spree){target=\_blank} as these features become available. [Learn more about Moonbeam](/learn/platform/networks/moonbeam/). -## Moonriver {: #moonriver } +## Moonriver {: #moonriver } In advance of deploying to the Polkadot MainNet, [Moonbeam launched Moonriver](https://moonbeam.network/announcements/moonriver-launch-kusama/){target=\_blank} as a parachain on the Kusama network. The parachain functionality is live on Kusama. @@ -31,11 +31,8 @@ Moonriver will offer parachain-related functionalities such as [XCMP](https://wi [Learn more about Moonriver](/learn/platform/networks/moonriver/). -## Moonbase Alpha {: #moonbase-alpha } +## Moonbase Alpha {: #moonbase-alpha } -This TestNet is a network hosted by PureStake. It features a parachain/relay chain scheme. The goal is to allow developers to test the Ethereum compatibility features of Moonbeam in a shared parachain environment without needing to run their own nodes or network. +This TestNet is a network hosted by OpsLayer. It features a parachain/relay chain scheme. The goal is to allow developers to test the Ethereum compatibility features of Moonbeam in a shared parachain environment without needing to run their own nodes or network. [Learn more about Moonbase Alpha](/learn/platform/networks/moonbase/). - - - diff --git a/learn/platform/technology.md b/learn/platform/technology.md index e1978e0cd..66a156c29 100644 --- a/learn/platform/technology.md +++ b/learn/platform/technology.md @@ -69,7 +69,7 @@ The [Ethereum pallet](https://polkadot-evm.github.io/frontier/frame/ethereum.htm When a user submits a raw Ethereum transaction, it converts into a Substrate transaction through the pallet Ethereum's `transact` extrinsic. Using the Ethereum pallet as the sole executor of the EVM pallet forces all of the data to be stored and transacted in an Ethereum-compatible way. This enables block explorers such as [Moonscan](/builders/get-started/explorers#moonscan){target=\_blank}, which is built by Etherscan, to be able to index block data. -Along with support for Ethereum-style data, the Ethereum pallet combined with the [RPC module](https://github.com/polkadot-evm/frontier/tree/master/client/rpc){target=\_blank} provides RPC support. This enables usage of [basic Ethereum JSON-RPC methods](/learn/core-concepts/rpc-support#basic-ethereum-json-rpc-methods){target=\_blank}, which ultimately allows existing Ethereum DApps to be deployed to Moonbeam with minimal changes. +Along with support for Ethereum-style data, the Ethereum pallet combined with the [RPC module](https://github.com/polkadot-evm/frontier/tree/master/client/rpc){target=\_blank} provides RPC support. This enables usage of [basic Ethereum JSON-RPC methods](/builders/pallets-precompiles/eth-rpc#basic-ethereum-json-rpc-methods){target=\_blank}, which ultimately allows existing Ethereum DApps to be deployed to Moonbeam with minimal changes. ### EVM Pallet {: #evm-pallet } diff --git a/node-operators/networks/run-a-node/docker.md b/node-operators/networks/run-a-node/docker.md index eb1debf85..a795219a2 100644 --- a/node-operators/networks/run-a-node/docker.md +++ b/node-operators/networks/run-a-node/docker.md @@ -95,14 +95,14 @@ For an overview of the flags used in the following start-up commands, plus addit docker run --network="host" -v "{{ networks.moonbeam.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbeam.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonbeam.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -112,14 +112,14 @@ For an overview of the flags used in the following start-up commands, plus addit docker run --network="host" -v "{{ networks.moonriver.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonriver.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonriver.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -129,14 +129,14 @@ For an overview of the flags used in the following start-up commands, plus addit docker run --network="host" -v "{{ networks.moonbase.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbase.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonbase.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -148,13 +148,13 @@ For an overview of the flags used in the following start-up commands, plus addit docker run -p 9944:9944 -v "/var/lib/moonbeam-data:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbeam.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain moonbeam \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -164,13 +164,13 @@ For an overview of the flags used in the following start-up commands, plus addit docker run -p 9944:9944 -v "/var/lib/moonriver-data:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonriver.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain moonriver \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -180,13 +180,13 @@ For an overview of the flags used in the following start-up commands, plus addit docker run -p 9944:9944 -v "/var/lib/alphanet-data:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbase.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain alphanet \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -200,15 +200,15 @@ For an overview of the flags used in the following start-up commands, plus addit docker run --network="host" -v "{{ networks.moonbeam.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbeam.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonbeam.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --unsafe-rpc-external \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -218,14 +218,14 @@ For an overview of the flags used in the following start-up commands, plus addit docker run -p 9944:9944 -v "/var/lib/moonbeam-data:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbeam.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain moonbeam \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --unsafe-rpc-external \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -239,16 +239,16 @@ For an overview of the flags used in the following start-up commands, plus addit docker run --network="host" -v "{{ networks.moonbeam.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbeam.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonbeam.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ # This is a comment --db-cache INSERT_RAM_IN_MB \ --frontier-backend-type sql \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -258,14 +258,14 @@ For an overview of the flags used in the following start-up commands, plus addit docker run -p 9944:9944 -v "/var/lib/moonbeam-data:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbeam.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain moonbeam \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --frontier-backend-type sql \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -279,14 +279,14 @@ For an overview of the flags used in the following start-up commands, plus addit docker run --network="host" -v "{{ networks.moonbeam.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbeam.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonbeam.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --collator \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -296,14 +296,14 @@ For an overview of the flags used in the following start-up commands, plus addit docker run --network="host" -v "{{ networks.moonriver.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonriver.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonriver.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --collator \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -313,14 +313,14 @@ For an overview of the flags used in the following start-up commands, plus addit docker run --network="host" -v "{{ networks.moonbase.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbase.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonbase.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --collator \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -332,13 +332,13 @@ For an overview of the flags used in the following start-up commands, plus addit docker run -p 9944:9944 -v "/var/lib/moonbeam-data:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbeam.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain moonbeam \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --collator \ --trie-cache-size 1073741824 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -348,13 +348,13 @@ For an overview of the flags used in the following start-up commands, plus addit docker run -p 9944:9944 -v "/var/lib/moonriver-data:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonriver.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain moonriver \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --collator \ --trie-cache-size 1073741824 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` @@ -364,13 +364,13 @@ For an overview of the flags used in the following start-up commands, plus addit docker run -p 9944:9944 -v "/var/lib/alphanet-data:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ moonbeamfoundation/moonbeam:{{ networks.moonbase.parachain_release_tag }} \ - --base-path=/data \ + --base-path /data \ --chain alphanet \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --collator \ --trie-cache-size 1073741824 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast ``` diff --git a/node-operators/networks/run-a-node/flags.md b/node-operators/networks/run-a-node/flags.md index 862ab479f..577bec96e 100644 --- a/node-operators/networks/run-a-node/flags.md +++ b/node-operators/networks/run-a-node/flags.md @@ -19,11 +19,6 @@ This guide will cover some of the most common flags and show you how to access a - **`--ws-port`** - - *deprecated as of [client v0.33.0](https://github.com/moonbeam-foundation/moonbeam/releases/tag/v0.33.0){target=\_blank}, use `--rpc-port` for HTTP and WS connections instead* - sets the unified port for both HTTP and WS connections. The default port for parachains is `{{ networks.parachain.ws }}` and `{{ networks.relay_chain.ws }}` for the embedded relay chain - **`--rpc-max-connections`** - specifies the maximum number of HTTP and WS server connections. The default is 100 - **`--ws-max-connections`** - *deprecated as of [client v0.33.0](https://github.com/moonbeam-foundation/moonbeam/releases/tag/v0.33.0){target=\_blank}, use `--rpc-max-connections` to adjust the combined HTTP and WS connection limit instead* - specifies the maximum number of HTTP and WS server connections. The default is 100 -- **`--execution`** - specifies the execution strategy that should be used by all execution contexts. The Substrate runtime is compiled into a native executable which is included locally as part of the node and a WebAssembly (Wasm) binary that is stored on-chain. The available options are: - - **`native`** - only execute with the native build - - **`wasm`** - only execute with the Wasm build - - **`both`** - execute with both native and Wasm builds - - **`nativeelsewasm`** - execute with the native build if possible and if it fails, then execute with Wasm - **`--wasm-execution`** - specifies the method for executing Wasm runtime code. The available options are: - **`compiled`** - this is the default and uses the [Wasmtime](https://github.com/paritytech/wasmtime){target=\_blank} compiled runtime - **`interpreted-i-know-what-i-do`** - uses the [wasmi interpreter](https://github.com/paritytech/wasmi){target=\_blank} diff --git a/node-operators/networks/run-a-node/overview.md b/node-operators/networks/run-a-node/overview.md index 42af13551..06ee9cade 100644 --- a/node-operators/networks/run-a-node/overview.md +++ b/node-operators/networks/run-a-node/overview.md @@ -86,7 +86,7 @@ There are a couple different guides to help you get started running a Moonbeam-b ## Debug, Trace and TxPool APIs {: #debug-trace-txpool-apis } -You can also gain access to some non-standard RPC methods by running a tracing node, which allow developers to inspect and debug transactions during runtime. Tracing nodes use a different Docker image than a standard Moonbase Alpha, Moonriver, or Moonbeam node. Check out the [Run a Tracing Node](/node-operators/networks/tracing-node) guide and be sure to switch to the right network tab throughout the instructions. Then to interact with your tracing node, check out the [Debug & Trace](/builders/build/eth-api/debug-trace) guide. +You can also gain access to some non-standard RPC methods by running a tracing node, which allow developers to inspect and debug transactions during runtime. Tracing nodes use a different Docker image than a standard Moonbase Alpha, Moonriver, or Moonbeam node. Check out the [Run a Tracing Node](/node-operators/networks/tracing-node) guide and be sure to switch to the right network tab throughout the instructions. Then to interact with your tracing node, check out the [Debug & Trace](/builders/json-rpc/debug-trace) guide. ## Logs and Troubleshooting {: #logs-and-troubleshooting } diff --git a/node-operators/networks/run-a-node/systemd.md b/node-operators/networks/run-a-node/systemd.md index 7d97728a1..bbc176569 100644 --- a/node-operators/networks/run-a-node/systemd.md +++ b/node-operators/networks/run-a-node/systemd.md @@ -188,14 +188,14 @@ For an overview of the flags used in the following start-up commands, plus addit SyslogFacility=local7 KillSignal=SIGHUP ExecStart={{ networks.moonbeam.node_directory }}/{{ networks.moonbeam.binary_name }} \ - --state-pruning=archive \ + --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --base-path {{ networks.moonbeam.node_directory }} \ --chain {{ networks.moonbeam.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast [Install] @@ -219,14 +219,14 @@ For an overview of the flags used in the following start-up commands, plus addit SyslogFacility=local7 KillSignal=SIGHUP ExecStart={{ networks.moonriver.node_directory }}/{{ networks.moonriver.binary_name }} \ - --state-pruning=archive \ + --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --base-path {{ networks.moonriver.node_directory }} \ --chain {{ networks.moonriver.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast [Install] @@ -250,14 +250,14 @@ For an overview of the flags used in the following start-up commands, plus addit SyslogFacility=local7 KillSignal=SIGHUP ExecStart={{ networks.moonbase.node_directory }}/{{ networks.moonbase.binary_name }} \ - --state-pruning=archive \ + --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --base-path {{ networks.moonbase.node_directory }} \ --chain {{ networks.moonbase.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast [Install] @@ -283,7 +283,7 @@ For an overview of the flags used in the following start-up commands, plus addit SyslogFacility=local7 KillSignal=SIGHUP ExecStart={{ networks.moonbeam.node_directory }}/{{ networks.moonbeam.binary_name }} \ - --state-pruning=archive \ + --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --base-path {{ networks.moonbeam.node_directory }} \ @@ -291,7 +291,7 @@ For an overview of the flags used in the following start-up commands, plus addit --name "INSERT_YOUR_NODE_NAME" \ --unsafe-rpc-external \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast [Install] @@ -317,7 +317,7 @@ For an overview of the flags used in the following start-up commands, plus addit SyslogFacility=local7 KillSignal=SIGHUP ExecStart={{ networks.moonbeam.node_directory }}/{{ networks.moonbeam.binary_name }} \ - --state-pruning=archive \ + --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --base-path {{ networks.moonbeam.node_directory }} \ @@ -325,7 +325,7 @@ For an overview of the flags used in the following start-up commands, plus addit --name "INSERT_YOUR_NODE_NAME" \ --frontier-backend-type sql \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast [Install] @@ -358,7 +358,7 @@ For an overview of the flags used in the following start-up commands, plus addit --chain {{ networks.moonbeam.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast [Install] @@ -389,7 +389,7 @@ For an overview of the flags used in the following start-up commands, plus addit --chain {{ networks.moonriver.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast [Install] @@ -420,7 +420,7 @@ For an overview of the flags used in the following start-up commands, plus addit --chain {{ networks.moonbase.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" \ --sync fast [Install] diff --git a/node-operators/networks/tracing-node.md b/node-operators/networks/tracing-node.md index e2a6d099d..0bb2b2808 100644 --- a/node-operators/networks/tracing-node.md +++ b/node-operators/networks/tracing-node.md @@ -21,12 +21,11 @@ Similarly to running a regular node, you can spin up a tracing node using Docker Spinning up a `debug`, `txpool`, or `tracing` node is similar to [running a full node](/node-operators/networks/run-a-node/overview/){target=\_blank}. However, there are some additional flags that you may want to enable specific tracing features: - - **`--ethapi=debug`** - optional flag that enables `debug_traceTransaction`, `debug_traceBlockByNumber`, and `debug_traceBlockByHash` - - **`--ethapi=trace`** - optional flag that enables `trace_filter` - - **`--ethapi=txpool`** - optional flag that enables `txpool_content`, `txpool_inspect`, and `txpool_status` - - **`--wasm-runtime-overrides=`** - **required** flag for tracing that specifies the path where the local Wasm runtimes are stored. If you're using Docker, the path is as follows: `/moonbeam/-substitutes-tracing`. Accepts the network as a parameter: `moonbeam`, `moonriver`, or `moonbase` (for development nodes and Moonbase Alpha) + - **`--ethapi debug`** - optional flag that enables `debug_traceTransaction`, `debug_traceBlockByNumber`, and `debug_traceBlockByHash` + - **`--ethapi trace`** - optional flag that enables `trace_filter` + - **`--ethapi txpool`** - optional flag that enables `txpool_content`, `txpool_inspect`, and `txpool_status` + - **`--wasm-runtime-overrides `** - **required** flag for tracing that specifies the path where the local Wasm runtimes are stored. If you're using Docker, the path is as follows: `/moonbeam/-substitutes-tracing`. Accepts the network as a parameter: `moonbeam`, `moonriver`, or `moonbase` (for development nodes and Moonbase Alpha) - **`--runtime-cache-size 64`** - **required** flag that configures the number of different runtime versions preserved in the in-memory cache to 64 - - **`--execution=wasm`** - sets the execution strategy that should be used by all execution contexts to `wasm`. In other words, this enables usage of the Wasm binary stored on-chain - **`--ethapi-trace-max-count `** β€” sets the maximum number of trace entries to be returned by the node. The default maximum number of trace entries a single request of `trace_filter` returns is `500` - **`-ethapi-trace-cache-duration `** β€” sets the duration (in seconds) after which the cache of `trace_filter,` for a given block, is discarded. The default amount of time blocks are stored in the cache is `300` seconds @@ -104,17 +103,17 @@ The complete command for running a tracing node is as follows: docker run --network="host" -v "{{ networks.moonbeam.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ {{ networks.moonbeam.tracing_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonbeam.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ - --ethapi=debug,trace,txpool \ - --wasm-runtime-overrides=/moonbeam/moonbeam-substitutes-tracing \ + --ethapi debug,trace,txpool \ + --wasm-runtime-overrides /moonbeam/moonbeam-substitutes-tracing \ --runtime-cache-size 64 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" ``` === "Moonriver" @@ -123,17 +122,17 @@ The complete command for running a tracing node is as follows: docker run --network="host" -v "{{ networks.moonriver.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ {{ networks.moonriver.tracing_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonriver.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ - --ethapi=debug,trace,txpool \ - --wasm-runtime-overrides=/moonbeam/moonriver-substitutes-tracing \ + --ethapi debug,trace,txpool \ + --wasm-runtime-overrides /moonbeam/moonriver-substitutes-tracing \ --runtime-cache-size 64 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" ``` === "Moonbase Alpha" @@ -142,17 +141,17 @@ The complete command for running a tracing node is as follows: docker run --network="host" -v "{{ networks.moonbase.node_directory }}:/data" \ -u $(id -u ${USER}):$(id -g ${USER}) \ {{ networks.moonbase.tracing_tag }} \ - --base-path=/data \ + --base-path /data \ --chain {{ networks.moonbase.chain_spec }} \ - --name="INSERT_YOUR_NODE_NAME" \ + --name "INSERT_YOUR_NODE_NAME" \ --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ - --ethapi=debug,trace,txpool \ - --wasm-runtime-overrides=/moonbeam/moonbase-substitutes-tracing \ + --ethapi debug,trace,txpool \ + --wasm-runtime-overrides /moonbeam/moonbase-substitutes-tracing \ --runtime-cache-size 64 \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" ``` === "Moonbeam Dev Node" @@ -161,16 +160,16 @@ The complete command for running a tracing node is as follows: docker run --network="host" \ -u $(id -u ${USER}):$(id -g ${USER}) \ {{ networks.development.tracing_tag }} \ - --name="INSERT_YOUR_NODE_NAME" \ - --ethapi=debug,trace,txpool \ - --wasm-runtime-overrides=/moonbeam/moonbase-substitutes-tracing \ + --name "INSERT_YOUR_NODE_NAME" \ + --ethapi debug,trace,txpool \ + --wasm-runtime-overrides /moonbeam/moonbase-substitutes-tracing \ --runtime-cache-size 64 \ --dev ``` You should see a terminal log similar to the following if you spun up a Moonbase Alpha tracing node: -![Debug API](/images/builders/build/eth-api/debug-trace/debug-trace-1.webp) +--8<-- 'code/builders/json-rpc/debug-trace/terminal/start-up-logs.md' ## Run a Tracing Node with Systemd {: #run-a-tracing-node-with-systemd } @@ -285,17 +284,17 @@ The next step is to create the systemd configuration file, you'll need to: SyslogFacility=local7 KillSignal=SIGHUP ExecStart={{ networks.moonbeam.node_directory }}/{{ networks.moonbeam.binary_name }} \ - --state-pruning=archive \ + --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --base-path {{ networks.moonbeam.node_directory }} \ - --ethapi=debug,trace,txpool \ - --wasm-runtime-overrides={{ networks.moonbeam.node_directory }}/wasm \ + --ethapi debug,trace,txpool \ + --wasm-runtime-overrides {{ networks.moonbeam.node_directory }}/wasm \ --runtime-cache-size 64 \ --chain {{ networks.moonbeam.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" [Install] WantedBy=multi-user.target @@ -318,17 +317,17 @@ The next step is to create the systemd configuration file, you'll need to: SyslogFacility=local7 KillSignal=SIGHUP ExecStart={{ networks.moonriver.node_directory }}/{{ networks.moonriver.binary_name }} \ - --state-pruning=archive \ + --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --base-path {{ networks.moonriver.node_directory }} \ - --ethapi=debug,trace,txpool \ - --wasm-runtime-overrides={{ networks.moonriver.node_directory }}/wasm \ + --ethapi debug,trace,txpool \ + --wasm-runtime-overrides {{ networks.moonriver.node_directory }}/wasm \ --runtime-cache-size 64 \ --chain {{ networks.moonriver.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" [Install] WantedBy=multi-user.target @@ -351,17 +350,17 @@ The next step is to create the systemd configuration file, you'll need to: SyslogFacility=local7 KillSignal=SIGHUP ExecStart={{ networks.moonbase.node_directory }}/{{ networks.moonbase.binary_name }} \ - --state-pruning=archive \ + --state-pruning archive \ --trie-cache-size 1073741824 \ --db-cache INSERT_RAM_IN_MB \ --base-path {{ networks.moonbase.node_directory }} \ - --ethapi=debug,trace,txpool \ - --wasm-runtime-overrides={{ networks.moonbase.node_directory }}/wasm \ + --ethapi debug,trace,txpool \ + --wasm-runtime-overrides {{ networks.moonbase.node_directory }}/wasm \ --runtime-cache-size 64 \ --chain {{ networks.moonbase.chain_spec }} \ --name "INSERT_YOUR_NODE_NAME" \ -- \ - --name="INSERT_YOUR_NODE_NAME (Embedded Relay)" + --name "INSERT_YOUR_NODE_NAME (Embedded Relay)" [Install] WantedBy=multi-user.target @@ -374,7 +373,7 @@ The next step is to create the systemd configuration file, you'll need to: --8<-- 'text/node-operators/networks/run-a-node/systemd/run-service.md' -![Service Status](/images/node-operators/networks/tracing-node/tracing-1.webp) +--8<-- 'code/node-operators/networks/tracing-node/terminal/status.md' You can also run the following command to see logs of the tracing node spinning up: @@ -384,8 +383,8 @@ journalctl -f -u moonbeam.service Your terminal should display logs similar to the following: -![Service logs of wasm rutime overrides being processed](/images/node-operators/networks/tracing-node/tracing-2.webp) +--8<-- 'code/node-operators/networks/tracing-node/terminal/logs.md' ## Using a Tracing Node {: #using-a-tracing-node } -To explore the different non-standard RPC methods available on Moonbeam, and how to use these methods with a tracing node, check out the [Debug & Trace](/builders/build/eth-api/debug-trace/) guide. +To explore the different non-standard RPC methods available on Moonbeam, and how to use these methods with a tracing node, check out the [Debug & Trace](/builders/json-rpc/debug-trace/) guide. diff --git a/tutorials/eth-api/hardhat-start-to-end.md b/tutorials/eth-api/hardhat-start-to-end.md index 24fd50e22..7f99ba17a 100644 --- a/tutorials/eth-api/hardhat-start-to-end.md +++ b/tutorials/eth-api/hardhat-start-to-end.md @@ -57,9 +57,9 @@ You will need to create a Hardhat project if you don't already have one. You can !!! note `npx` is used to run executables installed locally in your project. Although Hardhat can be installed globally, it is recommended to install it locally in each project so that you can control the version on a project by project basis. -5. A menu will appear which will allow you to create a new project or use a sample project. For this example, you can choose **Create an empty hardhat.config.js** +5. A menu will appear allowing you to create a new project or use a sample project. For this example, you can choose **Create an empty hardhat.config.js** -![Create an empty Hardhat project.](/images/tutorials/eth-api/hardhat-start-to-end/hardhat-1.webp) +--8<-- 'code/tutorials/eth-api/hardhat-start-to-end/terminal/hardhat-create.md' This will create a Hardhat config file (`hardhat.config.js`) in your project directory. @@ -171,8 +171,9 @@ For the examples in this guide, you'll need to add your private keys for your tw ```js // 1. Import the Hardhat Toolbox plugin require('@nomicfoundation/hardhat-toolbox'); +require('@nomicfoundation/hardhat-ignition-ethers'); -// 2. Create variables for your private keys from your pre-funded Moonbase Alpha +// 2. Create variables for your private keys from your pre-funded Moonbase Alpha // testing accounts and your Moonscan API key const privateKey = 'INSERT_PRIVATE_KEY'; const privateKey2 = 'INSERT_ANOTHER_PRIVATE_KEY'; @@ -186,20 +187,20 @@ module.exports = { moonbase: { url: '{{ networks.moonbase.rpc_url }}', chainId: {{ networks.moonbase.chain_id }}, // {{ networks.moonbase.hex_chain_id }} in hex - accounts: [privateKey, privateKey2] + accounts: [privateKey, privateKey2], }, dev: { url: '{{ networks.development.rpc_url }}', - chainId: 1281, // {{ networks.development.hex_chain_id }} in hex + chainId: {{ networks.development.chain_id }}, // {{ networks.development.hex_chain_id }} in hex accounts: [ '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133', // Alice's PK - '0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b' // Bob's PK - ] + '0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b', // Bob's PK + ], }, moonbeam: { url: '{{ networks.moonbeam.public_rpc_url }}', // Or insert your own RPC URL here - chainId: 1284, // {{ networks.moonbeam.hex_chain_id }} in hex - accounts: [privateKey, privateKey2] + chainId: {{ networks.moonbeam.chain_id }}, // {{ networks.moonbeam.hex_chain_id }} in hex + accounts: [privateKey, privateKey2], }, }, // 5. Set up your Moonscan API key for contract verification @@ -207,9 +208,9 @@ module.exports = { etherscan: { apiKey: { moonbaseAlpha: moonscanAPIKey, // Moonbase Moonscan API Key - moonbeam: moonscanAPIKey, // Moonbeam Moonscan API Key - } - } + moonbeam: moonscanAPIKey, // Moonbeam Moonscan API Key + }, + }, }; ``` @@ -226,15 +227,15 @@ To compile the contract you can simply run: npx hardhat compile ``` -![Learn how to compile your Solidity contracts with Hardhat.](/images/tutorials/eth-api/hardhat-start-to-end/hardhat-2.webp) +--8<-- 'code/tutorials/eth-api/hardhat-start-to-end/terminal/compile.md' -After compilation, an `artifacts` directory is created: it holds the bytecode and metadata of the contract, which are `.json` files. It’s a good idea to add this directory to your `.gitignore`. +After compilation, an `artifacts` directory is created: it holds the bytecode and metadata of the contract, which are `.json` files. Adding this directory to your `.gitignore` is a good idea. ## Testing {: #testing } -A robust smart contract development workflow is incomplete without a testing suite. Hardhat has a number of tools that make it easy to write and run tests. In this section, you'll learn the basics of testing your smart contracts and some more advanced techniques. +A robust smart contract development workflow is complete with a testing suite. Hardhat has a number of tools that make it easy to write and run tests. In this section, you'll learn the basics of testing your smart contracts and some more advanced techniques. -Hardhat tests are typically written with Mocha and Chai. [Mocha](https://mochajs.org/){target=\_blank} is a JavaScript testing framework and [Chai](https://www.chaijs.com/){target=\_blank} is a BDD/TDD JavaScript assertion library. BDD/TDD stands for behavior and test driven development respectively. Effective BDD/TDD necessitates writing your tests *before* writing your smart contract code. The structure of this tutorial doesn't strictly follow these guidelines, but you may wish to adopt these principles in your development workflow. Hardhat recommends using [Hardhat Toolbox](https://hardhat.org/hardhat-runner/docs/guides/migrating-from-hardhat-waffle){target=\_blank}, a plugin that bundles everything you need to get started with Hardhat, including Mocha and Chai. +Hardhat tests are typically written with Mocha and Chai. [Mocha](https://mochajs.org/){target=\_blank} is a JavaScript testing framework and [Chai](https://www.chaijs.com/){target=\_blank} is a BDD/TDD JavaScript assertion library. BDD/TDD stands for behavior and test-driven development respectively. Effective BDD/TDD necessitates writing your tests *before* writing your smart contract code. The structure of this tutorial doesn't strictly follow these guidelines, but you may wish to adopt these principles in your development workflow. Hardhat recommends using [Hardhat Toolbox](https://hardhat.org/hardhat-runner/docs/guides/migrating-from-hardhat-waffle){target=\_blank}, a plugin that bundles everything you need to get started with Hardhat, including Mocha and Chai. Because we will initially be running our tests on a local Moonbeam node, we need to specify Alice's address as the address of our target collator (Alice's account is the only collator for a local development node): @@ -264,7 +265,7 @@ To set up your test file, take the following steps: touch tests/Dao.js ``` -3. Then copy and paste the contents below to set up the initial structure of your test file. Be sure to read the comments as they can clarify the purpose of each line +3. Then copy and paste the contents below to set up the initial structure of your test file. Be sure to read the comments, as they can clarify the purpose of each line ```javascript // Import Ethers @@ -281,55 +282,68 @@ To set up your test file, take the following steps: Before we can run any test cases we'll need to launch a staking DAO with an initial configuration. Our setup here is relatively simple - we'll be deploying a staking DAO with a single administrator (the deployer) and then adding a new member to the DAO. This simple setup is perfect for demonstration purposes, but it's easy to imagine more complex configurations you'd like to test, such as a scenario with 100 DAO members or one with multiple admins of the DAO. -Mocha's `describe` function enables you to organize your tests. Multiple `describe` functions can be nested together. It's entirely optional but can be useful especially in complex projects with a large number of test cases. You can read more about constructing tests and [getting started with Mocha](https://mochajs.org/#getting-started){target=\_blank} on the Mocha docs site. +Mocha's `describe` function enables you to organize your tests. Multiple `describe` functions can be nested together. It's entirely optional but can be useful, especially in complex projects with many test cases. You can read more about constructing tests and [getting started with Mocha](https://mochajs.org/#getting-started){target=\_blank} on the Mocha docs site. -We'll define a function called `deployDao` that will contain the setup steps for our staking DAO. To configure your test file, add the following snippet: +We'll define a function called `deployDao` containing the setup steps for our staking DAO. To configure your test file, add the following snippet: ```javascript -// The describe function receives the name of a section of your test suite, and a -// callback. The callback must define the tests of that section. This callback -// can't be an async function +// The describe function receives the name of a section of your test suite, and a callback. The callback must define the tests of that section. This callback can't be an async function describe('Dao contract', function () { + let wallet1, wallet2; + + before(async function () { + // Get signers we defined in Hardhat config + const signers = await ethers.getSigners(); + wallet1 = signers[0]; + wallet2 = signers[1]; + }); + async function deployDao() { - // Get the contract factory and signers here - const [deployer, member1] = await ethers.getSigners(); - const delegationDao = await ethers.getContractFactory('DelegationDAO'); - - // Deploy the staking DAO and wait for the deployment transaction to be confirmed - const deployedDao = await delegationDao.deploy(targetCollator, deployer.address); - await deployedDao.waitForDeployment(); + const delegationDaoFactory = await ethers.getContractFactory( + 'DelegationDAO', + wallet2 + ); - // Return the deployed DAO and the first member of the DAO to allow the tests to - // access and interact with them - return { deployedDao, member1 }; + // Deploy the staking DAO and wait for the deployment transaction to be confirmed + try { + const deployedDao = await delegationDaoFactory.deploy( + targetCollator, + wallet2.address + ); + await deployedDao.waitForDeployment(); // Wait for the transaction to be mined + return { deployedDao }; + } catch (error) { + console.error('Failed to deploy contract:', error); + return null; // Return null to indicate failure + } } - - // The test cases should be added here -}); + // Insert additional tests here +}); ``` ### Writing your First Test Cases {: #writing-your-first-test-cases } -First, you'll create a subsection called `Deployment` to keep the test file organized. This will be nested within the `Dao contract` describe function. Next you'll define your first test case by using the `it` Mocha function. This first test is simply checking to see that the staking DAO is correctly storing the address of the target collator. +First, you'll create a subsection called `Deployment` to keep the test file organized. This will be nested within the `Dao contract` describe function. Next, you'll define your first test case by using the `it` Mocha function. This first test checks to see that the staking DAO correctly stores the address of the target collator. -Go ahead and add the below snippet to the end of your `Dao contract` function. +Add the snippet below to the end of your `Dao contract` function. ```javascript // You can nest calls to create subsections describe('Deployment', function () { - // Mocha's it function is used to define each of your tests. - // It receives the test name, and a callback function. - // If the callback function is async, Mocha will await it + // Mocha's it function is used to define each of your tests. It receives the test name, and a callback function. If the callback function is async, Mocha will await it. Test case to check that the correct target collator is stored it('should store the correct target collator in the DAO', async function () { - - // Set up our test environment by calling deployDao - const { deployedDao } = await deployDao(); + const deployment = await deployDao(); + if (!deployment || !deployment.deployedDao) { + throw new Error('Deployment failed; DAO contract was not deployed.'); + } + const { deployedDao } = deployment; // The expect function receives a value and wraps it in an assertion object. // This test will pass if the DAO stored the correct target collator - expect(await deployedDao.targetCollator()).to.equal(targetCollator); + expect(await deployedDao.getTarget()).to.equal( + '0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac' + ); }); - // The following test cases should be added here }); ``` @@ -337,9 +351,9 @@ describe('Deployment', function () { Now, add another test case. When a staking DAO is launched, it shouldn't have any funds. This test verifies that is indeed the case. Go ahead and add the following test case to your `Dao.js` file: ```javascript +// Test case to check that the DAO has 0 funds at inception it('should initially have 0 funds in the DAO', async function () { const { deployedDao } = await deployDao(); - // This test will pass if the DAO has no funds as expected before any contributions expect(await deployedDao.totalStake()).to.equal(0); }); @@ -347,39 +361,45 @@ it('should initially have 0 funds in the DAO', async function () { ### Function Reverts {: #function-reverts } -Now, you'll implement a more complex test case with a slightly different architecture. In prior examples, you've verified that a function returns an expected value. In this one, you'll be verifying that a function reverts. You'll also change the address of the caller to test an admin-only function. +Now, you'll implement a more complex test case with a slightly different architecture. In prior examples, you've verified that a function returns an expected value. In this one, you'll be verifying that a function reverts. You'll also change the caller's address to test an admin-only function. -In the [staking DAO contract](https://github.com/moonbeam-foundation/moonbeam-intro-course-resources/blob/main/delegation-dao-lesson-one/DelegationDAO.sol){target=\_blank}, only admins are authorized to add new members to the DAO. One could write a test that checks to see if the admin is authorized to add new members but perhaps a more important test is to ensure that *non-admins* can't add new members. To run this test case under a different account, you're going to ask for another address when you call `ethers.getSigners()` and specify the caller in the assertion with `connect(member1)`. Finally, after the function call you'll append `.to.be.reverted` to indicate that the test case is successful if the function reverts. And if it doesn't revert it's a failed test! +In the [staking DAO contract](https://github.com/moonbeam-foundation/moonbeam-intro-course-resources/blob/main/delegation-dao-lesson-one/DelegationDAO.sol){target=\_blank}, only admins are authorized to add new members to the DAO. One could write a test that checks to see if the admin is authorized to add new members but a more important test is to ensure that *non-admins* can't add new members. To run this test case under a different account, you will ask for another address when you call `ethers.getSigners()` and specify the caller in the assertion with `connect(member1)`. Finally, after the function call you'll append `.to.be.reverted` to indicate that the test case is successful if the function reverts. And if it doesn't revert, it's a failed test! ```javascript +// Test case to check that non-admins cannot grant membership it('should not allow non-admins to grant membership', async function () { - const { deployedDao, member1 } = await deployDao(); - - // We use connect to call grant_member from member1's account instead of admin. - // This test will succeed if the function call reverts and fails if the call succeeds - await expect( - deployedDao - .connect(member1) - .grant_member('0x0000000000000000000000000000000000000000') - ).to.be.reverted; + const { deployedDao } = await deployDao(); + // Connect the non-admin wallet to the deployed contract + const deployedDaoConnected = deployedDao.connect(wallet1); + const tx = deployedDaoConnected.grant_member( + '0x0000000000000000000000000000000000000000' + ); + + // Check that the transaction reverts, not specifying any particular reason + await expect(tx).to.be.reverted; }); ``` ### Signing Transactions from Other Accounts {: #signing-transactions-from-other-accounts } -For this example, you'll check to verify whether the newly added DAO member can call the `check_free_balance()` function of staking DAO, which has an access modifier such that only members can access it. +For this example, you'll verify whether the newly added DAO member can call the `check_free_balance()` function of staking DAO, which has an access modifier such that only members can access it. ```javascript +// Test case to check that members can access member only functions it('should only allow members to access member-only functions', async function () { - const { deployedDao, member1 } = await deployDao(); + const { deployedDao } = await deployDao(); - // Add a new member to the DAO - const transaction = await deployedDao.grant_member(member1.address); - await transaction.wait(); + // Connect the wallet1 to the deployed contract and grant membership + const deployedDaoConnected = deployedDao.connect(wallet2); + const grantTx = await deployedDaoConnected.grant_member(wallet1.address); + await grantTx.wait(); - // This test will succeed if the DAO member can call the member-only function. - // We use connect here to call the function from the account of the new member - expect(await deployedDao.connect(member1).check_free_balance()).to.equal(0); + // Check the free balance using the member's credentials + const checkTx = deployedDaoConnected.check_free_balance(); + + // Since check_free_balance() does not modify state, we expect it not to be reverted and check the balance + await expect(checkTx).to.not.be.reverted; + expect(await checkTx).to.equal(0); }); ``` @@ -395,12 +415,12 @@ If you've followed all of the prior sections, your [`Dao.js`](https://raw.github --8<-- 'code/tutorials/eth-api/hardhat-start-to-end/dao-js-test-file.js' ``` -Since our test cases encompass mostly configuration and setup of the staking DAO and don't involve actual delegation actions, we'll be running our tests on a Moonbeam development node (local node). Remember that Alice (`0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac`) is the only collator on a local development node. You can use the flag `--network moonbase` to run the tests using Moonbase Alpha. In that case, be sure that your deployer address is sufficiently funded with DEV tokens. +Since our test cases encompass mostly configuration and setup of the staking DAO and don't involve actual delegation actions, we'll be running our tests on a Moonbeam development node (local node). Remember that Alice (`0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac`) is the only collator on a local development node. You can use the flag `--network moonbase` to run the tests using Moonbase Alpha. In that case, ensure your deployer address is sufficiently funded with DEV tokens. !!! challenge - Try to create an additional test case that verifies the staking DAO successfully delegates to a collator once `minDelegationStk` is met. You'll need to test this on Moonbase Alpha rather than a local development node. + Try to create an additional test case that verifies the staking DAO successfully delegates to a collator once `minDelegationStk` is met. You must test this on Moonbase Alpha rather than a local development node. -First, make sure that your local Moonbeam node is running by following the [instructions for launching a local development node](/builders/get-started/networks/moonbeam-dev/){target=\_blank}. Take precautions because you could inadvertently send real funds to the Alice and Bob development accounts, which would result in a loss of those funds. +First, make sure that your local Moonbeam node is running by following the [instructions for launching a local development node](/builders/get-started/networks/moonbeam-dev/){target=\_blank}. Take precautions because you could inadvertently send real funds to the Alice and Bob development accounts, resulting in a loss of those funds. You can run your tests with the following command: @@ -410,79 +430,68 @@ npx hardhat test --network dev tests/Dao.js If everything was set up correctly, you should see output like the following: -![Run your test suite of test cases with Hardhat.](/images/tutorials/eth-api/hardhat-start-to-end/hardhat-3.webp) +--8<-- 'code/tutorials/eth-api/hardhat-start-to-end/terminal/test.md' ## Deploying to Moonbase Alpha {: #deploying-to-moonbase-alpha } -In the following steps, we'll be deploying the `DelegationDAO` to the Moonbase Alpha TestNet. Before deploying to Moonbase Alpha or Moonbeam, double check you're not using the Alice and Bob accounts, which should only be used on a local development node. +In the following steps, we'll deploy the `DelegationDAO` to the Moonbase Alpha TestNet. Before deploying to Moonbase Alpha or Moonbeam, double-check that you're not using the Alice and Bob accounts, which should only be used on a local development node. As a side note, `DelegationDAO` relies on [`StakingInterface.sol`](/builders/pallets-precompiles/precompiles/staking/){target=\_blank}, which is a Substrate-based offering unique to Moonbeam networks. The Hardhat Network and forked networks are simulated EVM environments which do not include the Substrate-based precompiles like `StakingInterface.sol`. Therefore, `DelegationDAO` will not work properly if deployed to the local default Hardhat Network or a [forked network](/builders/build/eth-api/dev-env/hardhat/#forking-moonbeam){target=\_blank}. -To deploy `DelegationDAO.sol`, you can write a simple script. You can create a new directory for the script and name it `scripts`: +To deploy `DelegationDAO`, you'll use Hardhat Ignition, a declarative framework for deploying smart contracts. Hardhat Ignition is designed to make it easy to manage recurring tasks surrounding smart contract deployment and testing. For more information about Hardhat Ignition and its architecture, be sure to check out the [Hardhat Ignition docs](https://hardhat.org/ignition/docs/getting-started#overview){target=\_blank}. -```bash -mkdir scripts -``` +To set up the proper file structure for your Ignition module, create a folder named `ignition` and a subdirectory called `modules`. Then, add a new file to it called `DelegationDao.js`. You can take all three of these steps with the following command: -Then add a new file to it called `deploy.js`: - -```bash -touch scripts/deploy.js +```sh +mkdir ignition ignition/modules && touch ignition/modules/DelegationDao.js ``` -Next, you need to write your deployment script which can be done using `ethers`. Because you'll be running it with Hardhat, you don't need to import any libraries. +Next, you can write your Hardhat Ignition module. To get started, take the following steps: -To get started, take the following steps: - -1. Specify the address of the active collator the DAO intends to delegate to. In this case, we've specified the address of the PS-1 Collator (note: this is different from the address of the Alice collator on a local development node) -2. Specify the deployer address as the admin of the DAO. It's important that the deployer be the admin of the DAO to ensure later tests work as expected -3. Create a local instance of the contract with the `getContractFactory` method -4. Use the `deploy` method that exists within this instance to instantiate the smart contract -5. Once deployed, you can fetch the address of the contract using the contract instance +1. Import the `buildModule` function from the Hardhat Ignition module +2. Export a module using `buildModule` +3. Specify the target collator candidate for the DAO to delegate to +4. Use the `getAccount` method to select the deployer account +5. Deploy `DelegationDAO.sol` +6. Return an object from the module. This makes the `DelegationDao` contract accessible for interaction in Hardhat tests and scripts When all is said and done your deployment script should look similar to the following: ```javascript -// 1. The PS-1 collator on Moonbase Alpha is chosen as the DAO's target -const targetCollator = '{{ networks.moonbase.staking.candidates.address1 }}'; - -async function main() { - // 2. Get the address of the deployer to later be set as the admin of the DAO - const [deployer] = await ethers.getSigners(); - console.log('Deploying contracts with the account:', deployer.address); - - // 3. Get an instance of DelegationDAO - const delegationDao = await ethers.getContractFactory('DelegationDAO'); - - // 4. Deploy the contract specifying two params: the desired collator to - // delegate to and the address of the deployer (the initial DAO admin) - const deployedDao = await delegationDao.deploy( - targetCollator, - deployer.address +// 1. Import the required function from the Hardhat Ignition module +const { buildModule } = require('@nomicfoundation/hardhat-ignition/modules'); + +// 2. Define and export your deployment module using `buildModule` +module.exports = buildModule('DelegationDAOModule', (m) => { + // 3. Specify the target collator address for the DAO + const targetCollator = '{{ networks.moonbase.staking.candidates.address1 }}'; + + // 4. Use the `getAccount` method to select the deployer account + const deployer = m.getAccount(0); + + // 5. Deploy the `DelegationDAO` contract + const delegationDao = m.contract( + 'DelegationDAO', + [targetCollator, deployer], + { + from: deployer, + } ); - await deployedDao.waitForDeployment(); - - // 5. Print out the address of the deployed staking DAO contract - console.log('DAO address:', deployedDao.target); -} -main() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); + // 6. Return an object from the module including references to deployed contracts, allowing the contract to be accessible for interaction in Hardhat tests and scripts + return { delegationDao }; +}); ``` -Make sure you've funded your accounts with Moonbase Alpha DEV tokens. You can now deploy `DelegationDAO.sol` using the `run` command and specifying `moonbase` as the network (as configured in the `hardhat.config.js` file): +To run the script and deploy the `DelegationDAO.sol` contract, use the following command, which requires you to specify the network name as defined in your `hardhat.config.js`. If you don't specify a network, Hardhat will deploy the contract to a local Hardhat network by default. -```bash -npx hardhat run --network moonbase scripts/deploy.js +```sh +npx hardhat ignition deploy ./ignition/modules/DelegationDao.js --network moonbase --deployment-id INSERT_YOUR_NAME ``` -After a few seconds, the contract is deployed, and you should see the address in the terminal. +You'll be prompted to confirm the network you wish to deploy to. After a few seconds after you confirm, the contract is deployed, and you'll see the contract address in the terminal. -![Deploy a Contract to Moonbase Alpha with Hardhat.](/images/tutorials/eth-api/hardhat-start-to-end/hardhat-4.webp) +--8<-- 'code/tutorials/eth-api/hardhat-start-to-end/terminal/deploy-moonbase.md' Congratulations, your contract is live on Moonbase Alpha! Save the address, as you will use it to interact with this contract instance in the next step. @@ -494,68 +503,63 @@ While it's possible to verify smart contracts on the [Moonscan website](https:// Before beginning the contract verification process, you'll need to [acquire a Moonscan API Key](/builders/build/eth-api/verify-contracts/etherscan-plugins/#generating-a-moonscan-api-key){target=\_blank}. Note that Moonbeam and Moonbase Alpha use the same [Moonbeam Moonscan](https://moonscan.io/){target=\_blank} API key, whereas you'll need a distinct API key for [Moonriver](https://moonriver.moonscan.io/){target=\_blank}. -To verify the contract, you will run the `verify` command and pass in the network where the `DelegationDao` contract is deployed, the address of the contract, and the two constructor arguments that you specified in your `deploy.js` file, namely, the address of the target collator and the address you deployed the smart contract with (sourced from the `hardhat.config.js` file). +To verify the contract, you will run the `ignition verify` command and pass the name of your deployment you set in the prior step. ```bash -npx hardhat verify --network moonbase INSERT_CONTRACT_ADDRESS {{ networks.moonbase.staking.candidates.address1 }} INSERT_DEPLOYER_ADDRESS +npx hardhat ignition verify INSERT_YOUR_NAME ``` !!! note If you're deploying `DelegationDAO.sol` verbatim without any changes, you may get an `Already Verified` error because Moonscan automatically recognizes and verifies smart contracts that have matching bytecode. Your contract will still show as verified, so there is nothing else you need to do. However, if you'd prefer to verify your own `DelegationDAO.sol`, you can make a small change to the contract (such as changing a comment) and repeating the compilation, deployment and verification steps. -In your terminal you should see the source code for your contract was successfully submitted for verification. If the verification was successful, you should see **Successfully verified contract** and there will be a link to the contract code on [Moonscan for Moonbase Alpha](https://moonbase.moonscan.io/){target=\_blank}. If the plugin returns an error, double check that your API key is configured correctly and that you have specified all necessary parameters in the verification command. You can refer to the [guide to the Hardhat Etherscan plugin](/builders/build/eth-api/verify-contracts/etherscan-plugins/){target=\_blank} for more information. +In your terminal, you should see the source code for your contract was successfully submitted for verification. If the verification was successful, you should see **Successfully verified contract** and there will be a link to the contract code on [Moonscan for Moonbase Alpha](https://moonbase.moonscan.io/){target=\_blank}. If the plugin returns an error, double check that your API key is configured correctly and that you have specified all necessary parameters in the verification command. You can refer to the [guide to the Hardhat Etherscan plugin](/builders/build/eth-api/verify-contracts/etherscan-plugins/){target=\_blank} for more information. + +--8<-- 'code/tutorials/eth-api/hardhat-start-to-end/terminal/verify-moonbase.md' -![Verify contracts on Moonbase Alpha using the Hardhat Etherscan plugin.](/images/tutorials/eth-api/hardhat-start-to-end/hardhat-5.webp) ## Deploying to Production on Moonbeam Mainnet {: #deploying-to-production-on-moonbeam-mainnet } !!! note `DelegationDAO.sol` is unreviewed and unaudited. It is designed only for demonstration purposes and not intended for production use. It may contain bugs or logic errors that could result in loss of funds. -In the following steps, we'll be deploying the `DelegationDAO` contract to the Moonbeam MainNet network. Remember to add the Moonbeam network to your [`hardhat.config.js`](#hardhat-configuration-file) and update the private keys of your accounts on Moonbeam if you haven't done so already. Before deploying `DelegationDAO` to Moonbeam, we need to change the address of the target collator, since our target collator on Moonbase Alpha does not exist on Moonbeam. Head to your deploy script and change the target collator to `0x1C86E56007FCBF759348dcF0479596a9857Ba105` or [another Moonbeam collator](https://apps.moonbeam.network/moonbeam/staking){target=\_blank} of your choice. Your `deploy.js` script should thus look like the following: +In the following steps, we'll be deploying the `DelegationDAO` contract to the Moonbeam MainNet network. Remember to add the Moonbeam network to your [`hardhat.config.js`](#hardhat-configuration-file) and update the private keys of your accounts on Moonbeam if you haven't done so already. Before deploying `DelegationDAO` to Moonbeam, we need to change the address of the target collator, since our target collator on Moonbase Alpha does not exist on Moonbeam. Head to your deploy script and change the target collator to `{{ networks.moonbeam.staking.candidates.address1 }}` or [another Moonbeam collator](https://apps.moonbeam.network/moonbeam/staking){target=\_blank} of your choice. Your deployment script, named `DelegationDao.js`, should thus look like the following: ```javascript -// 1. The moonbeam-foundation-03 collator on Moonbeam is chosen as the DAO's target -const targetCollator = '0x1C86E56007FCBF759348dcF0479596a9857Ba105'; - -async function main() { - // 2. Get the address of the deployer to later be set as the admin of the DAO - const [deployer] = await ethers.getSigners(); - console.log('Deploying contracts with the account:', deployer.address); - - // 3. Get an instance of DelegationDAO - const delegationDao = await ethers.getContractFactory('DelegationDAO'); - - // 4. Deploy the contract specifying two params: the desired collator to delegate - // to and the address of the deployer (synonymous with initial DAO admin) - const deployedDao = await delegationDao.deploy( - targetCollator, - deployer.address +// 1. Import the required function from the Hardhat Ignition module +const { buildModule } = require('@nomicfoundation/hardhat-ignition/modules'); + +// 2. Define and export your deployment module using `buildModule` +module.exports = buildModule('DelegationDAOModule', (m) => { + // 3. Specify the target collator address for the DAO + const targetCollator = '{{ networks.moonbeam.staking.candidates.address1 }}'; + + // 4. Use the `getAccount` method to select the deployer account + const deployer = m.getAccount(0); + + // 5. Deploy the `DelegationDAO` contract + const delegationDao = m.contract( + 'DelegationDAO', + [targetCollator, deployer], + { + from: deployer, + } ); - await deployedDao.waitForDeployment(); - console.log('DAO address:', deployedDao.target); -} + // 6. Return an object from the module including references to deployed contracts, allowing the contract to be accessible for interaction in Hardhat tests and scripts + return { delegationDao }; +}); -main() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); ``` -You can now deploy `DelegationDAO.sol` using the `run` command and specifying `moonbeam` as the network: +To run the script and deploy the `DelegationDAO.sol` contract, use the following command, which requires you to specify the network name as defined in your `hardhat.config.js`. If you don't specify a network, Hardhat will deploy the contract to a local Hardhat network by default. -```bash -npx hardhat run --network moonbeam scripts/deploy.js +```sh +npx hardhat ignition deploy ./ignition/modules/DelegationDao.js --network moonbeam --deployment-id INSERT_YOUR_NAME ``` -If you're using another Moonbeam network, make sure that you specify the correct network. The network name needs to match how it's defined in the `hardhat.config.js`. - -After a few seconds, the contract is deployed, and you should see the address in the terminal. +You'll be prompted to confirm the network you wish to deploy to. After a few seconds after you confirm, the contract is deployed, and you'll see the contract address in the terminal. -![Deploy a Contract to Moonbeam with Hardhat.](/images/tutorials/eth-api/hardhat-start-to-end/hardhat-6.webp) +--8<-- 'code/tutorials/eth-api/hardhat-start-to-end/terminal/deploy-moonbeam.md' Congratulations, your contract is live on Moonbeam! Save the address, as you will use it to interact with this contract instance in the next step. @@ -563,10 +567,10 @@ Congratulations, your contract is live on Moonbeam! Save the address, as you wil In this section, we'll be verifying the contract that was just deployed on Moonbeam. Before beginning the contract verification process, you'll need to [acquire a Moonscan API Key](/builders/build/eth-api/verify-contracts/etherscan-plugins/#generating-a-moonscan-api-key){target=\_blank}. Note that Moonbeam and Moonbase Alpha use the same [Moonbeam Moonscan](https://moonscan.io/){target=\_blank} API key, whereas you'll need a distinct API key for [Moonriver](https://moonriver.moonscan.io/){target=\_blank}. -To verify the contract, you will run the `verify` command and pass in the network where the `DelegationDao` contract is deployed, the address of the contract, and the two constructor arguments that you specified in your `deploy.js` file, namely, the address of the target collator and the address you deployed the smart contract with (sourced from your `hardhat.config.js` file). Remember that the target collator of the staking DAO on Moonbeam is different from the target collator of the staking DAO on Moonbase Alpha. +To verify the contract, you will run the `ignition verify` command and pass the name of your deployment you set in the prior step. ```bash -npx hardhat verify --network moonbeam INSERT_CONTRACT_ADDRESS 0x1C86E56007FCBF759348dcF0479596a9857Ba105 INSERT_DEPLOYER_ADDRESS +npx hardhat ignition verify INSERT_YOUR_NAME ``` !!! note @@ -574,9 +578,9 @@ npx hardhat verify --network moonbeam INSERT_CONTRACT_ADDRESS 0x1C86E56007FCBF75 In your terminal you should see the source code for your contract was successfully submitted for verification. If the verification was successful, you should see **Successfully verified contract** and there will be a link to the contract code on [Moonbeam Moonscan](https://moonscan.io/){target=\_blank}. If the plugin returns an error, double check that your API key is configured correctly and that you have specified all necessary parameters in the verification command. You can refer to the [guide to the Hardhat Etherscan plugin](/builders/build/eth-api/verify-contracts/etherscan-plugins/){target=\_blank} for more information. -![Verify contracts on Moonbeam using Hardhat Etherscan plugin.](/images/tutorials/eth-api/hardhat-start-to-end/hardhat-7.webp) +--8<-- 'code/tutorials/eth-api/hardhat-start-to-end/terminal/verify-moonbeam.md' -And that's it! We covered a lot of ground in this tutorial but there's more resources available if you'd like to go deeper, including the following: +And that's it! We covered a lot of ground in this tutorial, but there's more resources available if you'd like to go deeper, including the following: - [Hardhat guide to Testing Contracts](https://hardhat.org/hardhat-runner/docs/guides/test-contracts){target=\_blank} - [Writing tasks and scripts](https://hardhat.org/hardhat-runner/docs/guides/tasks-and-scripts){target=\_blank} diff --git a/tutorials/eth-api/how-to-build-a-dapp.md b/tutorials/eth-api/how-to-build-a-dapp.md index 24155af45..10c209496 100644 --- a/tutorials/eth-api/how-to-build-a-dapp.md +++ b/tutorials/eth-api/how-to-build-a-dapp.md @@ -54,7 +54,7 @@ This example is getting the balance (in DEV on Moonbase Alpha) of the `0xf24FF3a - `jsonrpc` β€” the JSON-RPC API version, usually "2.0" - `id` β€” an integer value that helps identify a response to a request. Can usually just keep it as ` -- `method` β€” the specific method to read/write data from/to the blockchain. You can see many of the [RPC methods on our docs site](/learn/core-concepts/rpc-support){target=\_blank} +- `method` β€” the specific method to read/write data from/to the blockchain. You can see many of the [RPC methods on our docs site](/builders/pallets-precompiles/eth-rpc){target=\_blank} - `params` β€” an array of the input parameters expected by the specific `method` There are also additional elements that can be added to JSON-RPC requests, but those four will be seen the most often. diff --git a/tutorials/interoperability/remote-batched-evm-calls.md b/tutorials/interoperability/remote-batched-evm-calls.md index cfb435b0a..a0238b072 100644 --- a/tutorials/interoperability/remote-batched-evm-calls.md +++ b/tutorials/interoperability/remote-batched-evm-calls.md @@ -16,7 +16,7 @@ To get the most out of this tutorial, you may wish to first familiarize yourself **The content of this tutorial is for educational purposes only!** -For this example, you'll be working on top of Moonbase Alpha (Moonbeam TestNet), which has its own relay chain called [Moonbase relay](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ffrag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/accounts){target=\_blank} (akin to the Polkadot relay chain). The relay chain token is called UNIT, while Moonbase Alpha's is called DEV. Importantly, you **must understand that sending incorrect XCM messages can result in the loss of funds.** Consequently, it is essential to test XCM features on a TestNet before moving to a production environment. +For this example, you'll be working on top of Moonbase Alpha (Moonbeam TestNet), which has its own relay chain called [Moonbase relay](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ffro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/accounts){target=\_blank} (akin to the Polkadot relay chain). The relay chain token is called UNIT, while Moonbase Alpha's is called DEV. Importantly, you **must understand that sending incorrect XCM messages can result in the loss of funds.** Consequently, it is essential to test XCM features on a TestNet before moving to a production environment. The goal of this tutorial is to show you how the [Batch Precompile](/builders/pallets-precompiles/precompiles/batch/){target=\_blank} can work in conjunction with [Polkadot's XCM](/builders/interoperability/xcm/overview/){target=\_blank} to allow you to trigger batch remote EVM calls on Moonbeam. To avoid adding complexity to this tutorial, the actual batch EVM calls we'll be making will be quite simple. We'll be initiating multiple mints of [planet ERC-20 test tokens on Moonbase Alpha](https://moonbase-minterc20.netlify.app/){target=\_blank}. Although we've chosen simple contract calls for demonstration purposes, there are lots more real-life defi examples that you may wish to emulate, such as token approvals and swaps, claiming rewards from multiple pools, or swapping and depositing into LP pools. @@ -34,7 +34,7 @@ The "happy path" of a remote batch EVM call dispatched via XCM is as follows: Considering all the steps summarized in the [introduction](#introduction), the following prerequisites need to be accounted for: -- You need to have UNITs on the relay chain to pay for transaction fees when sending the XCM. If you have a Moonbase Alpha account funded with DEV tokens, you can swap some DEV for xcUNIT here on [Moonbeam Swap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank}. Then withdraw the xcUNIT from Moonbase Alpha to [your account on the Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/accounts){target=\_blank} using [apps.moonbeam.network](https://apps.moonbeam.network/moonbase-alpha/){target=\_blank}. +- You need to have UNITs on the relay chain to pay for transaction fees when sending the XCM. If you have a Moonbase Alpha account funded with DEV tokens, you can swap some DEV for xcUNIT here on [Moonbeam Swap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank}. Then withdraw the xcUNIT from Moonbase Alpha to [your account on the Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/accounts){target=\_blank} using [apps.moonbeam.network](https://apps.moonbeam.network/moonbase-alpha/){target=\_blank}. --8<-- 'text/_common/faucet/faucet-list-item.md' - Your [Computed Origin account](/builders/interoperability/xcm/remote-execution/computed-origins){target=\_blank} must hold DEV tokens to fund the call to the Batch Precompile, and also pay for the XCM execution (although this could be paid in UNIT tokens as xcUNIT). We will calculate the Computed Origin account address in the next section @@ -174,12 +174,12 @@ To build the XCM message, which will initiate the remote EVM call through XCM, a ``` !!! note - You can also get the SCALE encoded calldata by manually building the extrinsic in [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/extrinsics){target=\_blank}. + You can also get the SCALE encoded calldata by manually building the extrinsic in [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/extrinsics){target=\_blank}. Let's go through each of the main components of the snippet shown above: 1. Provide the input data for the call. This includes: - - [Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ffrag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/accounts){target=\_blank} endpoint URL to create the provider + - [Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ffro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/accounts){target=\_blank} endpoint URL to create the provider - Amount of tokens (in Wei) to withdraw from the Computed Origin account. For this example, `0.01` tokens are more than enough. To understand how to get this value, please refer to the [XCM fee page](/builders/interoperability/xcm/core-concepts/weights-fees/#moonbeam-reserve-assets){target=\_blank} - The [multilocation of the DEV token](/builders/interoperability/xcm/xc-registration/assets/#register-moonbeam-native-assets){target=\_blank}, as seen by Moonbase Alpha - The weight for the `transact` XCM instruction. This can be obtained by multiplying `25000` by the gas limit obtained before. It is recommended to add approximately 10% more of the estimated value. You can read more about this value on the [Remote EVM Calls through XCM](/builders/interoperability/xcm/remote-execution/remote-evm-calls/#build-xcm-remote-evm){target=\_blank} page @@ -232,7 +232,7 @@ Once you have the code set up, you can execute it with `node`, and the XCM messa And that is it! You've sent an XCM message, which performed a remote EVM call to the Batch Precompile via XCM and resulted in the minting of MARS and NEPT ERC-20 tokens. But let's go into more detail about what happened. -This action will emit different events. The first one is only relevant [in the relay chain](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/explorer/query/10936471){target=\_blank}, and it is named `xcmPallet.Sent`, which is from the `xcmPallet.send` extrinsic. In [Moonbase Alpha](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer/query/4626493){target=\_blank}, the following events emitted by the `parachainSystem.setValidationData` extrinsic (where all the inbound XCM messages are processed) are of interest: +This action will emit different events. The first one is only relevant [in the relay chain](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/explorer/query/10936471){target=\_blank}, and it is named `xcmPallet.Sent`, which is from the `xcmPallet.send` extrinsic. In [Moonbase Alpha](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer/query/4626493){target=\_blank}, the following events emitted by the `parachainSystem.setValidationData` extrinsic (where all the inbound XCM messages are processed) are of interest: - `parachainSystem.DownwardMessagesReceived` β€” states that there was an XCM message received - `evm.Log` β€” internal events emitted by the different contract calls. The structure is the same: contract address, topics, and relevant data diff --git a/tutorials/interoperability/remote-staking-xcm.md b/tutorials/interoperability/remote-staking-xcm.md index 561636502..ae9f56ac5 100644 --- a/tutorials/interoperability/remote-staking-xcm.md +++ b/tutorials/interoperability/remote-staking-xcm.md @@ -20,7 +20,7 @@ There are actually two possible approaches for staking on Moonbeam remotely via For development purposes this tutorial is written for Moonbase Alpha and Moonbase relay using TestNet funds. For prerequisites: -- A Moonbase Alpha relay chain account funded with some UNIT, the native token of the Moonbase relay chain. If you have a Moonbase Alpha account funded with DEV tokens, you can swap some DEV for xcUNIT here on [Moonbeam Swap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank}. Then withdraw the xcUNIT from Moonbase Alpha to [your account on the Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/accounts){target=\_blank} using [apps.moonbeam.network](https://apps.moonbeam.network/moonbase-alpha/){target=\_blank} +- A Moonbase Alpha relay chain account funded with some UNIT, the native token of the Moonbase relay chain. If you have a Moonbase Alpha account funded with DEV tokens, you can swap some DEV for xcUNIT here on [Moonbeam Swap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank}. Then withdraw the xcUNIT from Moonbase Alpha to [your account on the Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/accounts){target=\_blank} using [apps.moonbeam.network](https://apps.moonbeam.network/moonbase-alpha/){target=\_blank} - You'll need to [calculate the Computed Origin account](#calculating-your-computed-origin-account) of your Moonbase Alpha relay chain account and fund it with DEV tokens. --8<-- 'text/_common/faucet/faucet-list-item.md' diff --git a/tutorials/interoperability/uniswapv2-swap-xcm.md b/tutorials/interoperability/uniswapv2-swap-xcm.md index 373b9128b..5d26c1939 100644 --- a/tutorials/interoperability/uniswapv2-swap-xcm.md +++ b/tutorials/interoperability/uniswapv2-swap-xcm.md @@ -31,7 +31,7 @@ With the steps outlined, some prerequisites need to be taken into account, let's Considering all the steps summarized in the [introduction](#introduction), the following prerequisites need to be accounted for: -- You need to have UNITs on the relay chain to pay for transaction fees when sending the XCM. If you have a Moonbase Alpha account funded with DEV tokens, you can swap some DEV for xcUNIT here on [Moonbeam Swap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank}. Then withdraw the xcUNIT from Moonbase Alpha to [your account on the Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/accounts){target=\_blank} using [apps.moonbeam.network](https://apps.moonbeam.network/moonbase-alpha/){target=\_blank} +- You need to have UNITs on the relay chain to pay for transaction fees when sending the XCM. If you have a Moonbase Alpha account funded with DEV tokens, you can swap some DEV for xcUNIT here on [Moonbeam Swap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank}. Then withdraw the xcUNIT from Moonbase Alpha to [your account on the Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/accounts){target=\_blank} using [apps.moonbeam.network](https://apps.moonbeam.network/moonbase-alpha/){target=\_blank} - Your [Computed Origin account](/builders/interoperability/xcm/remote-execution/computed-origins){target=\_blank} must hold `DEV` tokens to fund the Uniswap V2 swap, and also pay for the XCM execution (although this could be paid in UNIT tokens as `xcUNIT`). We will calculate the Computed Origin account address in the next section --8<-- 'text/_common/faucet/faucet-list-item.md' @@ -185,7 +185,7 @@ To build the XCM message, which will initiate the remote EVM call through XCM, a ``` !!! note - You can also get the SCALE encoded calldata by manually building the extrinsic in [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/extrinsics){target=\_blank}. + You can also get the SCALE encoded calldata by manually building the extrinsic in [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/extrinsics){target=\_blank}. Let's go through each of the main components of the snippet shown above: @@ -243,7 +243,7 @@ Once you have the code set up, you can execute it with `node`, and the XCM messa And that is it! You've sent an XCM message, which performed a remote EVM call via XCM and resulted in an Uniswap V2-styled swap in Moonbase Alpha. But let's go into more detail about what happened. -This action will emit different events. The first one is the only relevant [in the relay chain](https://polkadot.js.org/apps/?rpc=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network#/explorer/query/0x85cad5f3cef5d578f6acc60c721ece14842be332fa333c9b9eafdfe078bc0290){target=\_blank}, and it is named `xcmPallet.Sent`, which is from the `xcmPallet.send` extrinsic. In [Moonbase Alpha](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer/query/0x1f60aeb1f2acbc2cf6e19b7ad969661f21f4847f7b40457c459e7d39f6bc0779){target=\_blank}, the following events emitted by the `parachainSystem.setValidationData` extrinsic (where all the inbound XCM messages are processed) are of interest: +This action will emit different events. The first one is the only relevant [in the relay chain](https://polkadot.js.org/apps/?rpc=wss://fro-moon-rpc-1-moonbase-relay-rpc-1.moonbase.ol-infra.network#/explorer/query/0x85cad5f3cef5d578f6acc60c721ece14842be332fa333c9b9eafdfe078bc0290){target=\_blank}, and it is named `xcmPallet.Sent`, which is from the `xcmPallet.send` extrinsic. In [Moonbase Alpha](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer/query/0x1f60aeb1f2acbc2cf6e19b7ad969661f21f4847f7b40457c459e7d39f6bc0779){target=\_blank}, the following events emitted by the `parachainSystem.setValidationData` extrinsic (where all the inbound XCM messages are processed) are of interest: - `parachainSystem.DownwardMessagesReceived` β€” states that there was an XCM message received - `evm.Log` β€” internal events emitted by the different contract calls. The structure is the same: contract address, the topics, and relevant data diff --git a/variables.yml b/variables.yml index d0398dcb8..3ed402830 100644 --- a/variables.yml +++ b/variables.yml @@ -1,7 +1,7 @@ networks: development: - build_tag: v0.36.0 - tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.36.0-2801-7ae4 + build_tag: v0.37.2 + tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.37.2-2902-latest rpc_url: http://127.0.0.1:9944 wss_url: ws://127.0.0.1:9944 chain_id: 1281 @@ -15,10 +15,10 @@ networks: hex_chain_id: '0x507' chain_spec: alphanet block_explorer: https://moonbase.moonscan.io/ - spec_version: runtime-2801 - parachain_release_tag: v0.36.0 # must be in this exact format for links to work - parachain_sha256sum: a4d143b6fd3c4fc43341df5a0e9a608180fee1b2e5c2ade12c4bcb4da49fa93a - tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.36.0-2801-7ae4 + spec_version: runtime-2902 + parachain_release_tag: v0.37.2 # must be in this exact format for links to work + parachain_sha256sum: 71242b8cdf2b97fba4aadb7d6050e0b46eaacafae6bcde9b5f5534aff620d144 + tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.37.2-2902-latest gas_block: 15,000,000 gas_block_numbers_only: 15000000 gas_tx: 12,995,000 @@ -328,8 +328,8 @@ networks: max_del_per_can: 300 max_del_per_del: 100 candidates: - address1: '0x4c5A56ed5A4FF7B09aA86560AfD7d383F4831Cce' - address2: '0x623c9E50647a049F92090fe55e22cC0509872FB6' + address1: '0x12E7BCCA9b1B15f33585b5fc898B967149BDb9a5' + address2: '0x95651f0777D9c7EF56f2edEe62D5F28743E0635a' treasury: current_council_members: 2 motion_duration_days: 3 @@ -428,9 +428,9 @@ networks: chain_id: 1285 hex_chain_id: '0x505' node_directory: /var/lib/moonriver-data - parachain_release_tag: v0.36.0 - parachain_sha256sum: a4d143b6fd3c4fc43341df5a0e9a608180fee1b2e5c2ade12c4bcb4da49fa93a - tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.36.0-2801-7ae4 + parachain_release_tag: v0.37.2 + parachain_sha256sum: 71242b8cdf2b97fba4aadb7d6050e0b46eaacafae6bcde9b5f5534aff620d144 + tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.37.2-2902-latest chain_spec: moonriver block_explorer: https://moonriver.moonscan.io/ spec_version: runtime-2801 @@ -775,9 +775,9 @@ networks: chain_id: 1284 hex_chain_id: '0x504' node_directory: /var/lib/moonbeam-data - parachain_release_tag: v0.36.0 - parachain_sha256sum: a4d143b6fd3c4fc43341df5a0e9a608180fee1b2e5c2ade12c4bcb4da49fa93a - tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.36.0-2801-7ae4 + parachain_release_tag: v0.37.2 + parachain_sha256sum: 71242b8cdf2b97fba4aadb7d6050e0b46eaacafae6bcde9b5f5534aff620d144 + tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.37.2-2902-latest chain_spec: moonbeam block_explorer: https://moonscan.io spec_version: runtime-2801 @@ -992,6 +992,8 @@ networks: min_del_stake: 50 max_del_per_can: 300 max_del_per_del: 100 + candidates: + address1: '0x1C86E56007FCBF759348dcF0479596a9857Ba105' treasury: current_council_members: 5 motion_duration_days: 3