diff --git a/.ai/categories/basics.md b/.ai/categories/basics.md index 0a49145f5..830319b8d 100644 --- a/.ai/categories/basics.md +++ b/.ai/categories/basics.md @@ -1077,7 +1077,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -1411,8 +1411,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, diff --git a/.ai/categories/dapps.md b/.ai/categories/dapps.md index a6a18ceb2..7c768a299 100644 --- a/.ai/categories/dapps.md +++ b/.ai/categories/dapps.md @@ -1330,7 +1330,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -1664,8 +1664,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -3513,7 +3513,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -3529,7 +3529,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3552,7 +3552,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3582,7 +3582,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3610,7 +3610,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3640,7 +3640,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3668,7 +3668,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3692,7 +3692,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3718,7 +3718,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3744,7 +3744,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3769,7 +3769,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3794,7 +3794,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3820,7 +3820,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3850,7 +3850,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3878,7 +3878,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3904,7 +3904,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3929,7 +3929,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3955,7 +3955,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3981,7 +3981,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4006,7 +4006,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4031,7 +4031,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4054,7 +4054,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4086,7 +4086,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4119,7 +4119,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4142,7 +4142,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4165,7 +4165,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4188,7 +4188,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4211,7 +4211,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4234,7 +4234,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4260,7 +4260,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4286,7 +4286,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4319,7 +4319,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", diff --git a/.ai/categories/infrastructure.md b/.ai/categories/infrastructure.md index 69b03a2dc..5332bb8c3 100644 --- a/.ai/categories/infrastructure.md +++ b/.ai/categories/infrastructure.md @@ -1078,7 +1078,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -1412,8 +1412,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -3706,7 +3706,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -3722,7 +3722,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3745,7 +3745,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3775,7 +3775,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3803,7 +3803,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3833,7 +3833,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3861,7 +3861,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3885,7 +3885,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3911,7 +3911,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3937,7 +3937,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3962,7 +3962,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3987,7 +3987,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4013,7 +4013,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4043,7 +4043,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4071,7 +4071,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4097,7 +4097,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4122,7 +4122,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4148,7 +4148,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4174,7 +4174,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4199,7 +4199,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4224,7 +4224,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4247,7 +4247,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4279,7 +4279,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4312,7 +4312,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4335,7 +4335,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4358,7 +4358,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4381,7 +4381,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4404,7 +4404,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4427,7 +4427,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4453,7 +4453,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4479,7 +4479,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4512,7 +4512,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", diff --git a/.ai/categories/networks.md b/.ai/categories/networks.md index b5196bf9c..981d6abe2 100644 --- a/.ai/categories/networks.md +++ b/.ai/categories/networks.md @@ -1078,7 +1078,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -1412,8 +1412,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -2981,7 +2981,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -2997,7 +2997,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3020,7 +3020,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3050,7 +3050,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3078,7 +3078,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3108,7 +3108,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3136,7 +3136,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3160,7 +3160,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3186,7 +3186,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3212,7 +3212,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3237,7 +3237,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3262,7 +3262,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3288,7 +3288,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3318,7 +3318,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3346,7 +3346,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3372,7 +3372,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3397,7 +3397,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3423,7 +3423,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3449,7 +3449,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3474,7 +3474,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3499,7 +3499,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3522,7 +3522,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3554,7 +3554,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3587,7 +3587,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3610,7 +3610,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3633,7 +3633,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3656,7 +3656,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3679,7 +3679,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3702,7 +3702,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3728,7 +3728,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3754,7 +3754,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3787,7 +3787,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", diff --git a/.ai/categories/parachains.md b/.ai/categories/parachains.md index 9bf26202a..a3262e6c5 100644 --- a/.ai/categories/parachains.md +++ b/.ai/categories/parachains.md @@ -3134,7 +3134,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -3468,8 +3468,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -6027,7 +6027,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -6043,7 +6043,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6066,7 +6066,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6096,7 +6096,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6124,7 +6124,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6154,7 +6154,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6182,7 +6182,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6206,7 +6206,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6232,7 +6232,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6258,7 +6258,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6283,7 +6283,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6308,7 +6308,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6334,7 +6334,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6364,7 +6364,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6392,7 +6392,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6418,7 +6418,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6443,7 +6443,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6469,7 +6469,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6495,7 +6495,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6520,7 +6520,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6545,7 +6545,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6568,7 +6568,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6600,7 +6600,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6633,7 +6633,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6656,7 +6656,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6679,7 +6679,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6702,7 +6702,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6725,7 +6725,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6748,7 +6748,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6774,7 +6774,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6800,7 +6800,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6833,7 +6833,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", diff --git a/.ai/categories/polkadot-protocol.md b/.ai/categories/polkadot-protocol.md index 20636f67e..6c1c6e006 100644 --- a/.ai/categories/polkadot-protocol.md +++ b/.ai/categories/polkadot-protocol.md @@ -1379,7 +1379,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -1713,8 +1713,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -3485,7 +3485,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -3501,7 +3501,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3524,7 +3524,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3554,7 +3554,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3582,7 +3582,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3612,7 +3612,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3640,7 +3640,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3664,7 +3664,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3690,7 +3690,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3716,7 +3716,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3741,7 +3741,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3766,7 +3766,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3792,7 +3792,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3822,7 +3822,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3850,7 +3850,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3876,7 +3876,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3901,7 +3901,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3927,7 +3927,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3953,7 +3953,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -3978,7 +3978,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4003,7 +4003,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4026,7 +4026,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4058,7 +4058,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4091,7 +4091,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4114,7 +4114,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4137,7 +4137,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4160,7 +4160,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4183,7 +4183,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4206,7 +4206,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4232,7 +4232,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4258,7 +4258,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -4291,7 +4291,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", diff --git a/.ai/categories/reference.md b/.ai/categories/reference.md index 1558bb58a..20635ede3 100644 --- a/.ai/categories/reference.md +++ b/.ai/categories/reference.md @@ -386,7 +386,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -402,7 +402,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -425,7 +425,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -455,7 +455,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -483,7 +483,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -513,7 +513,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -541,7 +541,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -565,7 +565,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -591,7 +591,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -617,7 +617,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -642,7 +642,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -667,7 +667,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -693,7 +693,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -723,7 +723,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -751,7 +751,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -777,7 +777,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -802,7 +802,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -828,7 +828,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -854,7 +854,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -879,7 +879,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -904,7 +904,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -927,7 +927,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -959,7 +959,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -992,7 +992,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -1015,7 +1015,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -1038,7 +1038,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -1061,7 +1061,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -1084,7 +1084,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -1107,7 +1107,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -1133,7 +1133,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -1159,7 +1159,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -1192,7 +1192,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", diff --git a/.ai/categories/smart-contracts.md b/.ai/categories/smart-contracts.md index 9cccbf569..dbec9f29d 100644 --- a/.ai/categories/smart-contracts.md +++ b/.ai/categories/smart-contracts.md @@ -149,13 +149,13 @@ The following block explorers are available for PolkaVM smart contracts, providi -### BlockScout -BlockScout is an open-source explorer platform with a user-friendly interface adapted for PolkaVM contracts. It excels at detailed contract analytics and provides developers with comprehensive API access. -- [Polkadot Hub TestNet BlockScout](https://blockscout-passet-hub.parity-testnet.parity.io/){target=\_blank} +### Routescan -![](/images/smart-contracts/explorers/explorers-01.webp) +Routescan delivers multi-chain explorer capabilities with specialized support for PolkaVM environments. + +- [Polkadot Hub TestNet Routescan](https://polkadot.testnet.routescan.io/){target=\_blank} --- @@ -636,7 +636,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t Chain ID ```text - 420420422 + 420420417 ``` --- @@ -644,7 +644,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t RPC URL ```text - https://testnet-passet-hub-eth-rpc.polkadot.io + https://services.polkadothub-rpc.com/testnet ``` --- @@ -652,7 +652,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t Block explorer URL ```text - https://blockscout-passet-hub.parity-testnet.parity.io/ + https://polkadot.testnet.routescan.io/ ``` @@ -660,7 +660,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t You will need testnet tokens to perform transactions and engage with smart contracts on any chain. Here's how to obtain Paseo (PAS) tokens for testing purposes: -1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank}. If the desired network is not already selected, choose it from the Network drop-down. +1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank}. If the desired network is not already selected, choose it from the Network drop-down. 2. Copy your address linked to the TestNet and paste it into the designated field. @@ -1747,8 +1747,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -1837,7 +1837,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -2098,7 +2098,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -2432,8 +2432,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -2816,8 +2816,8 @@ createProvider(PROVIDER_RPC.rpc, PROVIDER_RPC.chainId, PROVIDER_RPC.name); ```js const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet' }; ``` @@ -2845,8 +2845,8 @@ With the provider set up, you can start querying the blockchain. For instance, t }; const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -3110,8 +3110,8 @@ You can create a `deploy.js` script in the root of your project to achieve this. ```js title="scripts/deploy.js" const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -3212,8 +3212,8 @@ You can create a `deploy.js` script in the root of your project to achieve this. }; const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -3303,9 +3303,9 @@ const interactWithStorageContract = async ( }; const providerConfig = { - name: 'asset-hub-smart-contracts', - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + name: 'polkadot-hub', + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, }; const mnemonic = 'INSERT_MNEMONIC' @@ -3444,8 +3444,8 @@ createProvider(PROVIDER_RPC.rpc); ```js const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet' }; ``` @@ -3469,8 +3469,8 @@ With the provider set up, you can start querying the blockchain. For instance, t }; const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -3732,8 +3732,8 @@ You can create a `deploy.js` script in the `scripts` directory of your project t ```js title="scripts/deploy.js" const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -3840,8 +3840,8 @@ You can create a `deploy.js` script in the `scripts` directory of your project t }; const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -3922,7 +3922,7 @@ const updateStorage = async (config) => { }; const config = { - rpcUrl: 'https://testnet-passet-hub-eth-rpc.polkadot.io', + rpcUrl: 'https://services.polkadothub-rpc.com/testnet', privateKey: 'INSERT_PRIVATE_KEY', contractAddress: 'INSERT_CONTRACT_ADDRESS', }; @@ -4441,13 +4441,13 @@ Polkadot has a faucet that distributes free TestNet tokens to developers for tes ## Get Test Tokens -For Polkadot Hub TestNet, you can use the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank} to obtain test tokens. Here's how to do it: +For Polkadot Hub TestNet, you can use the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank} to obtain test tokens. Here's how to do it: -1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank}. If the desired network is not already selected, choose it from the **Network** drop-down. This example uses the Polkadot Hub TestNet. +1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank}. If the desired network is not already selected, choose it from the **Network** drop-down. This example uses the Polkadot Hub TestNet. 2. Copy your address linked to the TestNet and paste it into the designated field. 3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly. -![Polkadot Faucet](/images/smart-contracts/faucet/faucet-1.gif) +![Polkadot Faucet](/images/smart-contracts/faucet/faucet-01.gif) ## Things to Consider @@ -5530,7 +5530,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -5546,7 +5546,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5569,7 +5569,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5599,7 +5599,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5627,7 +5627,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5657,7 +5657,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5685,7 +5685,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5709,7 +5709,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5735,7 +5735,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5761,7 +5761,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5786,7 +5786,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5811,7 +5811,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5837,7 +5837,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5867,7 +5867,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5895,7 +5895,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5921,7 +5921,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5946,7 +5946,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5972,7 +5972,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5998,7 +5998,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6023,7 +6023,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6048,7 +6048,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6071,7 +6071,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6103,7 +6103,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6136,7 +6136,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6159,7 +6159,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6182,7 +6182,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6205,7 +6205,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6228,7 +6228,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6251,7 +6251,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6277,7 +6277,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6303,7 +6303,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6336,7 +6336,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -9322,14 +9322,14 @@ To use Hardhat with Polkadot Hub, define the network configuration in your `hard import { vars } from 'hardhat/config'; const config: HardhatUserConfig = { - solidity: '0.8.28', - networks: { + solidity: '0.8.28', + networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, - accounts: [vars.get('PRIVATE_KEY')], + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, + accounts: [vars.get('PRIVATE_KEY')], }, - }, + }, }; export default config; @@ -9629,11 +9629,11 @@ After setting up the [Public Client](https://viem.sh/docs/clients/public#public- ```js title="src/fetchLastBlock.ts" import { createPublicClient, http } from 'viem'; - const transport = http('https://testnet-passet-hub-eth-rpc.polkadot.io'); // TODO: change to paseo asset hub once ready + const transport = http('https://services.polkadothub-rpc.com/testnet'); // Configure the Polkadot Hub chain const polkadotHubTestnet = { - id: 420420422, + id: 420420417, name: 'Polkadot Hub TestNet', network: 'polkadot-hub-testnet', nativeCurrency: { @@ -9643,7 +9643,7 @@ After setting up the [Public Client](https://viem.sh/docs/clients/public#public- }, rpcUrls: { default: { - http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const; @@ -10118,7 +10118,7 @@ export const config = createConfig({ // Configure the Polkadot Hub chain const assetHub = { - id: 420420422, + id: 420420417, name: 'polkadot-hub-testnet', network: 'polkadot-hub-testnet', nativeCurrency: { @@ -10128,7 +10128,7 @@ export const config = createConfig({ }, rpcUrls: { default: { - http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const; @@ -10505,58 +10505,29 @@ To get started with MetaMask, you need to install the [MetaMask extension](https For example, to connect to the Polkadot Hub TestNet via MetaMask, you need to follow these steps: -1. Open the MetaMask extension and click on the network icon to switch to the Polkadot Hub TestNet. +1. Open the MetaMask extension and click on the network dropdown to switch to the Polkadot Hub TestNet. ![](/images/smart-contracts/integrations/wallets/wallets-1.webp){: .browser-extension} -2. Click on the **Add a custom network** button. +2. Click on the **Custom** tab. ![](/images/smart-contracts/integrations/wallets/wallets-2.webp){: .browser-extension} -3. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\_blank} section for copy and paste parameters). +3. Click on the **Add a custom network** button. ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension} -4. Click on **Polkadot Hub TestNet** to switch the network. - - ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension} - -The steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters. - -### SubWallet - -[SubWallet](https://www.subwallet.app/){target=\_blank} is a popular non-custodial wallet solution for Polkadot and Ethereum ecosystems. It offers seamless integration with Polkadot SDK-based networks while maintaining Ethereum compatibility, making the wallet an ideal choice for users and developers to interact with Polkadot Hub. - -SubWallet now fully supports the [Polkadot Hub TestNet](/smart-contracts/connect/){target=\_blank} where developers can deploy and interact with Ethereum-compatible, Solidity smart contracts. +4. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\_blank} section for copy and paste parameters). -You can easily view and manage your Paseo native token (PAS) using the Ethereum RPC endpoint (Passet Hub EVM) or the Substrate node RPC endpoint (passet-hub). - -??? code "Polkadot Hub TestNet" - You can see support here for Polkadot Hub's TestNet. The **Passet Hub EVM** network uses an ETH RPC endpoint, and the **passet-hub** uses a Substrate endpoint. - The ETH RPC endpoint will let you send transactions that follow an ETH format, while the Substrate endpoint will follow a Substrate transaction format. - Note the PAS token, which is the native token of the Polkadot Hub TestNet. - - ![](/images/smart-contracts/integrations/wallets/subwallet-PAS.webp){: .browser-extension} - -To connect to Polkadot Hub TestNet using SubWallet, follow these steps: - -1. Install the [SubWallet browser extension](https://chromewebstore.google.com/detail/subwallet-polkadot-wallet/onhogfjeacnfoofkfgppdlbmlmnplgbn?hl=en){target=\_blank} and set up your wallet by following the on-screen instructions, or refer to our [step-by-step guide](https://docs.subwallet.app/main/extension-user-guide/getting-started/install-subwallet){target=\_blank} for assistance. - -2. After setting up your wallet, click the List icon at the top left corner of the extension window to open **Settings**. - - ![](/images/smart-contracts/integrations/wallets/subwallet-01.webp){: .browser-extension} - -3. Scroll down and select **Manage networks**. + ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension} - ![](/images/smart-contracts/integrations/wallets/subwallet-02.webp){: .browser-extension} +5. Click on **Polkadot Hub TestNet** to switch the network. -4. In the Manage network screen, either scroll down or type in the search bar to find the networks. Once done, enable the toggle next to the network name. + ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension} - ![](/images/smart-contracts/integrations/wallets/subwallet-03.webp){: .browser-extension} +The steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters. - You are now ready to use SubWallet to interact with [Polkadot Hub TestNet](/smart-contracts/connect/#networks-details){target=\_blank} seamlessly! -![](/images/smart-contracts/integrations/wallets/subwallet-04.webp){: .browser-extension} ### Talisman @@ -10566,37 +10537,28 @@ To use Talisman with Polkadot Hub TestNet: 1. Install the [Talisman extension](https://talisman.xyz/download){target=\_blank} and set up your wallet by following the on-screen instructions. -2. Once installed, click on the Talisman icon in your browser extensions and click on the **Settings** button. +2. Once installed, click on the Talisman icon in your browser extensions and click on the **More** button. ![](/images/smart-contracts/integrations/wallets/wallets-5.webp){: .browser-extension} -3. Click the button **All settings**. +3. Click the button **Manage Networks**. ![](/images/smart-contracts/integrations/wallets/wallets-6.webp){: .browser-extension} -4. Go to the **Networks & Tokens** section. +4. Click on the **+ Add network** button. ![](/images/smart-contracts/integrations/wallets/wallets-7.webp) -5. Click the **Manage networks** button. +5. Fill in the form with the required parameters and click the ave** button. ![](/images/smart-contracts/integrations/wallets/wallets-8.webp) -6. Click the **+ Add network** button. +6. After that, you will see the **Polkadot Hub TestNet** in the list. ![](/images/smart-contracts/integrations/wallets/wallets-9.webp) -7. Fill in the form with the required parameters and click the **Add network** button. - - ![](/images/smart-contracts/integrations/wallets/wallets-10.webp) - -8. After that, you can switch to the Polkadot Hub TestNet by clicking on the network icon and selecting **Polkadot Hub TestNet**. - - ![](/images/smart-contracts/integrations/wallets/wallets-11.webp) - After selecting the network, Talisman will automatically configure the necessary RPC URL and chain ID for you. You can now use Talisman to interact with the Polkadot Hub TestNet. - ## Conclusion Choosing the right wallet for Polkadot Hub interactions depends on your specific requirements and familiarity with different interfaces. MetaMask provides a familiar entry point for developers with Ethereum experience, while Talisman offers deeper integration with Polkadot's unique features and native support for both EVM and Substrate accounts. By properly configuring your wallet connection, you gain access to the full spectrum of Polkadot Hub's capabilities. @@ -10661,7 +10623,7 @@ web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC)) Replace `INSERT_RPC_URL` with the appropriate value. For instance, to connect to Polkadot Hub TestNet, use the following parameter: ```python - PROVIDER_RPC = 'https://testnet-passet-hub-eth-rpc.polkadot.io' + PROVIDER_RPC = 'https://services.polkadothub-rpc.com/testnet' ``` With the Web3 provider set up, start querying the blockchain. For instance, you can use the following code snippet to fetch the latest block number of the chain. @@ -10674,7 +10636,7 @@ With the Web3 provider set up, start querying the blockchain. For instance, you def main(): try: - PROVIDER_RPC = "https://testnet-passet-hub-eth-rpc.polkadot.io" + PROVIDER_RPC = "https://services.polkadothub-rpc.com/testnet" web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC)) latest_block = web3.eth.block_number print("Last block: " + str(latest_block)) diff --git a/.ai/categories/tooling.md b/.ai/categories/tooling.md index 0464dbd0e..b3d65ffa6 100644 --- a/.ai/categories/tooling.md +++ b/.ai/categories/tooling.md @@ -149,13 +149,13 @@ The following block explorers are available for PolkaVM smart contracts, providi -### BlockScout -BlockScout is an open-source explorer platform with a user-friendly interface adapted for PolkaVM contracts. It excels at detailed contract analytics and provides developers with comprehensive API access. -- [Polkadot Hub TestNet BlockScout](https://blockscout-passet-hub.parity-testnet.parity.io/){target=\_blank} +### Routescan -![](/images/smart-contracts/explorers/explorers-01.webp) +Routescan delivers multi-chain explorer capabilities with specialized support for PolkaVM environments. + +- [Polkadot Hub TestNet Routescan](https://polkadot.testnet.routescan.io/){target=\_blank} --- @@ -1370,7 +1370,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   @@ -1704,8 +1704,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -2088,8 +2088,8 @@ createProvider(PROVIDER_RPC.rpc, PROVIDER_RPC.chainId, PROVIDER_RPC.name); ```js const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet' }; ``` @@ -2117,8 +2117,8 @@ With the provider set up, you can start querying the blockchain. For instance, t }; const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -2382,8 +2382,8 @@ You can create a `deploy.js` script in the root of your project to achieve this. ```js title="scripts/deploy.js" const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -2484,8 +2484,8 @@ You can create a `deploy.js` script in the root of your project to achieve this. }; const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -2575,9 +2575,9 @@ const interactWithStorageContract = async ( }; const providerConfig = { - name: 'asset-hub-smart-contracts', - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + name: 'polkadot-hub', + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, }; const mnemonic = 'INSERT_MNEMONIC' @@ -2716,8 +2716,8 @@ createProvider(PROVIDER_RPC.rpc); ```js const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet' }; ``` @@ -2741,8 +2741,8 @@ With the provider set up, you can start querying the blockchain. For instance, t }; const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -3004,8 +3004,8 @@ You can create a `deploy.js` script in the `scripts` directory of your project t ```js title="scripts/deploy.js" const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -3112,8 +3112,8 @@ You can create a `deploy.js` script in the `scripts` directory of your project t }; const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -3194,7 +3194,7 @@ const updateStorage = async (config) => { }; const config = { - rpcUrl: 'https://testnet-passet-hub-eth-rpc.polkadot.io', + rpcUrl: 'https://services.polkadothub-rpc.com/testnet', privateKey: 'INSERT_PRIVATE_KEY', contractAddress: 'INSERT_CONTRACT_ADDRESS', }; @@ -5389,7 +5389,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -5405,7 +5405,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5428,7 +5428,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5458,7 +5458,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5486,7 +5486,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5516,7 +5516,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5544,7 +5544,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5568,7 +5568,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5594,7 +5594,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5620,7 +5620,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5645,7 +5645,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5670,7 +5670,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5696,7 +5696,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5726,7 +5726,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5754,7 +5754,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5780,7 +5780,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5805,7 +5805,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5831,7 +5831,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5857,7 +5857,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5882,7 +5882,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5907,7 +5907,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5930,7 +5930,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5962,7 +5962,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -5995,7 +5995,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6018,7 +6018,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6041,7 +6041,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6064,7 +6064,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6087,7 +6087,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6110,7 +6110,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6136,7 +6136,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6162,7 +6162,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -6195,7 +6195,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -11271,14 +11271,14 @@ To use Hardhat with Polkadot Hub, define the network configuration in your `hard import { vars } from 'hardhat/config'; const config: HardhatUserConfig = { - solidity: '0.8.28', - networks: { + solidity: '0.8.28', + networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, - accounts: [vars.get('PRIVATE_KEY')], + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, + accounts: [vars.get('PRIVATE_KEY')], }, - }, + }, }; export default config; @@ -11578,11 +11578,11 @@ After setting up the [Public Client](https://viem.sh/docs/clients/public#public- ```js title="src/fetchLastBlock.ts" import { createPublicClient, http } from 'viem'; - const transport = http('https://testnet-passet-hub-eth-rpc.polkadot.io'); // TODO: change to paseo asset hub once ready + const transport = http('https://services.polkadothub-rpc.com/testnet'); // Configure the Polkadot Hub chain const polkadotHubTestnet = { - id: 420420422, + id: 420420417, name: 'Polkadot Hub TestNet', network: 'polkadot-hub-testnet', nativeCurrency: { @@ -11592,7 +11592,7 @@ After setting up the [Public Client](https://viem.sh/docs/clients/public#public- }, rpcUrls: { default: { - http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const; @@ -12067,7 +12067,7 @@ export const config = createConfig({ // Configure the Polkadot Hub chain const assetHub = { - id: 420420422, + id: 420420417, name: 'polkadot-hub-testnet', network: 'polkadot-hub-testnet', nativeCurrency: { @@ -12077,7 +12077,7 @@ export const config = createConfig({ }, rpcUrls: { default: { - http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const; @@ -12541,58 +12541,29 @@ To get started with MetaMask, you need to install the [MetaMask extension](https For example, to connect to the Polkadot Hub TestNet via MetaMask, you need to follow these steps: -1. Open the MetaMask extension and click on the network icon to switch to the Polkadot Hub TestNet. +1. Open the MetaMask extension and click on the network dropdown to switch to the Polkadot Hub TestNet. ![](/images/smart-contracts/integrations/wallets/wallets-1.webp){: .browser-extension} -2. Click on the **Add a custom network** button. +2. Click on the **Custom** tab. ![](/images/smart-contracts/integrations/wallets/wallets-2.webp){: .browser-extension} -3. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\_blank} section for copy and paste parameters). +3. Click on the **Add a custom network** button. ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension} -4. Click on **Polkadot Hub TestNet** to switch the network. - - ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension} - -The steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters. - -### SubWallet - -[SubWallet](https://www.subwallet.app/){target=\_blank} is a popular non-custodial wallet solution for Polkadot and Ethereum ecosystems. It offers seamless integration with Polkadot SDK-based networks while maintaining Ethereum compatibility, making the wallet an ideal choice for users and developers to interact with Polkadot Hub. - -SubWallet now fully supports the [Polkadot Hub TestNet](/smart-contracts/connect/){target=\_blank} where developers can deploy and interact with Ethereum-compatible, Solidity smart contracts. - -You can easily view and manage your Paseo native token (PAS) using the Ethereum RPC endpoint (Passet Hub EVM) or the Substrate node RPC endpoint (passet-hub). - -??? code "Polkadot Hub TestNet" - You can see support here for Polkadot Hub's TestNet. The **Passet Hub EVM** network uses an ETH RPC endpoint, and the **passet-hub** uses a Substrate endpoint. - The ETH RPC endpoint will let you send transactions that follow an ETH format, while the Substrate endpoint will follow a Substrate transaction format. - Note the PAS token, which is the native token of the Polkadot Hub TestNet. +4. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\_blank} section for copy and paste parameters). - ![](/images/smart-contracts/integrations/wallets/subwallet-PAS.webp){: .browser-extension} - -To connect to Polkadot Hub TestNet using SubWallet, follow these steps: - -1. Install the [SubWallet browser extension](https://chromewebstore.google.com/detail/subwallet-polkadot-wallet/onhogfjeacnfoofkfgppdlbmlmnplgbn?hl=en){target=\_blank} and set up your wallet by following the on-screen instructions, or refer to our [step-by-step guide](https://docs.subwallet.app/main/extension-user-guide/getting-started/install-subwallet){target=\_blank} for assistance. - -2. After setting up your wallet, click the List icon at the top left corner of the extension window to open **Settings**. - - ![](/images/smart-contracts/integrations/wallets/subwallet-01.webp){: .browser-extension} - -3. Scroll down and select **Manage networks**. + ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension} - ![](/images/smart-contracts/integrations/wallets/subwallet-02.webp){: .browser-extension} +5. Click on **Polkadot Hub TestNet** to switch the network. -4. In the Manage network screen, either scroll down or type in the search bar to find the networks. Once done, enable the toggle next to the network name. + ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension} - ![](/images/smart-contracts/integrations/wallets/subwallet-03.webp){: .browser-extension} +The steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters. - You are now ready to use SubWallet to interact with [Polkadot Hub TestNet](/smart-contracts/connect/#networks-details){target=\_blank} seamlessly! -![](/images/smart-contracts/integrations/wallets/subwallet-04.webp){: .browser-extension} ### Talisman @@ -12602,37 +12573,28 @@ To use Talisman with Polkadot Hub TestNet: 1. Install the [Talisman extension](https://talisman.xyz/download){target=\_blank} and set up your wallet by following the on-screen instructions. -2. Once installed, click on the Talisman icon in your browser extensions and click on the **Settings** button. +2. Once installed, click on the Talisman icon in your browser extensions and click on the **More** button. ![](/images/smart-contracts/integrations/wallets/wallets-5.webp){: .browser-extension} -3. Click the button **All settings**. +3. Click the button **Manage Networks**. ![](/images/smart-contracts/integrations/wallets/wallets-6.webp){: .browser-extension} -4. Go to the **Networks & Tokens** section. +4. Click on the **+ Add network** button. ![](/images/smart-contracts/integrations/wallets/wallets-7.webp) -5. Click the **Manage networks** button. +5. Fill in the form with the required parameters and click the ave** button. ![](/images/smart-contracts/integrations/wallets/wallets-8.webp) -6. Click the **+ Add network** button. +6. After that, you will see the **Polkadot Hub TestNet** in the list. ![](/images/smart-contracts/integrations/wallets/wallets-9.webp) -7. Fill in the form with the required parameters and click the **Add network** button. - - ![](/images/smart-contracts/integrations/wallets/wallets-10.webp) - -8. After that, you can switch to the Polkadot Hub TestNet by clicking on the network icon and selecting **Polkadot Hub TestNet**. - - ![](/images/smart-contracts/integrations/wallets/wallets-11.webp) - After selecting the network, Talisman will automatically configure the necessary RPC URL and chain ID for you. You can now use Talisman to interact with the Polkadot Hub TestNet. - ## Conclusion Choosing the right wallet for Polkadot Hub interactions depends on your specific requirements and familiarity with different interfaces. MetaMask provides a familiar entry point for developers with Ethereum experience, while Talisman offers deeper integration with Polkadot's unique features and native support for both EVM and Substrate accounts. By properly configuring your wallet connection, you gain access to the full spectrum of Polkadot Hub's capabilities. @@ -12697,7 +12659,7 @@ web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC)) Replace `INSERT_RPC_URL` with the appropriate value. For instance, to connect to Polkadot Hub TestNet, use the following parameter: ```python - PROVIDER_RPC = 'https://testnet-passet-hub-eth-rpc.polkadot.io' + PROVIDER_RPC = 'https://services.polkadothub-rpc.com/testnet' ``` With the Web3 provider set up, start querying the blockchain. For instance, you can use the following code snippet to fetch the latest block number of the chain. @@ -12710,7 +12672,7 @@ With the Web3 provider set up, start querying the blockchain. For instance, you def main(): try: - PROVIDER_RPC = "https://testnet-passet-hub-eth-rpc.polkadot.io" + PROVIDER_RPC = "https://services.polkadothub-rpc.com/testnet" web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC)) latest_block = web3.eth.block_number print("Last block: " + str(latest_block)) @@ -13324,7 +13286,7 @@ const config: HardhatUserConfig = { polkadotTestNet: { type: "http", chainType: "l1", - url: 'http://127.0.0.1:8545', + url: 'https://services.polkadothub-rpc.com/testnet', accounts: [process.env.PRIVATE_KEY || ''], }, }, @@ -13381,7 +13343,7 @@ You should see output similar to: npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet WARNING: You are using Node.js 23.11.0 which is not supported by Hardhat. Please upgrade to 22.10.0 or a later LTS version (even major version number) - βœ” Confirm deploy to network polkadotTestNet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestNet (420420417)? … yes Hardhat Ignition πŸš€ Deploying [ StorageModule ] Batch #1 @@ -13426,7 +13388,7 @@ To interact with Polkadot Hub, you need to set up a [Public Client](https://viem import { createPublicClient, http, createWalletClient, custom } from 'viem' import 'viem/window'; -const transport = http('http://127.0.0.1:8545') // TODO: change to the paseo asset hub RPC URL when it's available +const transport = http('https://services.polkadothub-rpc.com/testnet') // Configure the Polkadot Testnet Hub chain export const polkadotTestnet = { @@ -13440,7 +13402,7 @@ export const polkadotTestnet = { }, rpcUrls: { default: { - http: ['http://127.0.0.1:8545'], // TODO: change to the paseo asset hub RPC URL + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const diff --git a/.ai/pages/get-support-ai-ready-docs.md b/.ai/pages/get-support-ai-ready-docs.md index 8e27d211c..b14ecc7bb 100644 --- a/.ai/pages/get-support-ai-ready-docs.md +++ b/.ai/pages/get-support-ai-ready-docs.md @@ -17,7 +17,7 @@ Polkadot provides files to make documentation content available in a structure o These AI-ready files do not include any persona or system prompts. They are purely informational and can be used without conflicting with your existing agent or tool prompting. -## Download LLM Files +## Access LLM Files | Category | Description | File | Actions | |----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| diff --git a/.ai/pages/get-support-explore-resources.md b/.ai/pages/get-support-explore-resources.md deleted file mode 100644 index ca629b331..000000000 --- a/.ai/pages/get-support-explore-resources.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: Subscribe to Updates -description: Find Polkadot developer resources, tutorials, forums, governance proposals, and community platforms like StackExchange, Reddit, and YouTube. -url: https://docs.polkadot.com/get-support/explore-resources/ ---- - -# Ask the Community and Explore Resources - -Looking for answers beyond the documentation? These platforms are full of useful content and experienced developers sharing insights. - -## 🧠 Stack Exchange - -- Browse commonly asked technical questions. -- Ask your own and get detailed responses from experienced devs. - -πŸ‘‰ **[Visit Polkadot Stack Exchange](https://substrate.stackexchange.com/){target=\_blank}** - -## 🧡 Reddit: r/Polkadot - -- General Polkadot discussions and community perspectives. -- Developer questions are welcome β€” just tag them appropriately. - -πŸ‘‰ **[Visit r/Polkadot](https://www.reddit.com/r/Polkadot/){target=\_blank}** - -## πŸ’¬ Discord (Community Threads Only) - -- Beyond the official support threads, most channels are community-driven. -- Great place to connect with fellow builders and share insights. - -πŸ‘‰ **[Join the Polkadot Discord](https://polkadot-discord.w3f.tools/){target=\_blank}** - -## πŸŽ₯ YouTube: @PolkadotNetwork - -- Developer tutorials -- Ecosystem interviews -- Event recordings and walkthroughs - -πŸ‘‰ **[Watch on YouTube](https://www.youtube.com/@PolkadotNetwork){target=\_blank}** - -## Community-Led Platforms and Ecosystem Updates - -Stay in sync with what's happening across the Polkadot ecosystem β€” from official announcements to community-driven insights and governance activity. - -### πŸ”· X (Twitter): Official Accounts - -- [@PolkadotDevs](https://x.com/PolkadotDevs){target=\_blank}: Updates for developers -- [@Polkadot](https://x.com/Polkadot){target=\_blank}: Network-wide news -- [@Kusamanetwork](https://x.com/kusamanetwork){target=\_blank}: Kusama-specific updates -- [@Web3Foundation](https://x.com/web3foundation){target=\_blank}: Grants, research, and ecosystem programs - -### πŸ” X (Twitter): Community Accounts - -- [@PolkadotDeploy](https://x.com/PolkadotDeploy){target=\_blank}: News from the deployment portal and tooling updates - -### πŸ—£οΈ Polkadot Forum - -- Join community discussions around the direction of the ecosystem. - -πŸ‘‰ **[Visit the Polkadot Forum](https://forum.polkadot.network/){target=\_blank}** - -### πŸ§‘β€βš–οΈ Polkassembly: OpenGov - -- Explore and vote on governance proposals for Polkadot and Kusama. -- Help shape the future of the network. - -πŸ‘‰ **[Explore on Polkassembly](https://polkadot.polkassembly.io/){target=\_blank}** - -### πŸ“Έ Instagram - -- **[@Polkadotnetwork](https://www.instagram.com/polkadotnetwork){target=\_blank}**: Visual highlights from the ecosystem - _(Note: not developer-specific)_ diff --git a/.ai/pages/get-support-get-in-touch.md b/.ai/pages/get-support-get-in-touch.md deleted file mode 100644 index 31629828a..000000000 --- a/.ai/pages/get-support-get-in-touch.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: Get in Touch -description: Developer support for Polkadot via Telegram, Matrix, and Discord. Get help with parachains, smart contracts, nodes, and ecosystem tools. -url: https://docs.polkadot.com/get-support/get-in-touch/ ---- - -# Get in Touch Directly - -## Need Help Fast? - -Use one of the channels below to get live technical support or ask questions. - - - -Prefer to see all available channels? Below are your options. - -## πŸ“± Telegram: Polkadot Developer Support - -The fastest way to get support. - -- **Who’s there:** DevRel team and active developer community. -- **Response time:** Within **2 business days (usually faster)**. -- **Topics:** Any developer-related question is welcome. - -πŸ‘‰ **[Join Telegram](https://t.me/substratedevs){target=\_blank}** - -## πŸ”Œ Discord: Polkadot Official Server - -Focused support for smart contracts and general developer chat. - -- **Smart contracts:** Ask in `#solidity-smart-contracts` and `#ink_smart-contracts`. -- **General developer support:** Ask in `#solidity-smart-contracts`. -- **Response time:** Within **1 business day (usually faster)**. -- **Other topics:** Community-led discussion only. - -πŸ‘‰ **[Join Discord](https://polkadot-discord.w3f.tools/){target=\_blank}** - -## 🧬 Matrix: Polkadot Developer Support - -This is the **support channel** staffed by engineers from **Parity**, **Web3 Foundation**, and **Polkadot DevRel**. - -- **Who’s there:** Parity, W3F, DevRel, and community contributors. -- **Response time:** Within **1 business day (usually faster)**. -- **Topics:** Full-spectrum developer support. -- Bridged with Telegram (all messages synced). - -πŸ‘‰ **[Join Matrix](https://matrix.to/#/#substratedevs:matrix.org){target=\_blank}** - ---- - -Not sure where to start? - -**Join [Telegram](#telegram-polkadot-developer-support)**: Let us know what you need, and we’ll help you get unstuck. diff --git a/.ai/pages/get-support.md b/.ai/pages/get-support.md index 8505b9539..c07eb386e 100644 --- a/.ai/pages/get-support.md +++ b/.ai/pages/get-support.md @@ -4,42 +4,121 @@ description: Start here to get developer support for Polkadot. Connect with the url: https://docs.polkadot.com/get-support/ --- -# Need Help Fast? +# Polkadot Developer Support + +You're already in the docs β€” solid start. But sometimes you need more: answers, real examples, someone to talk to. This support hub is here to help you move forward β€” faster. + +If something’s missing, unclear, or broken β€” **[tell us](https://github.com/polkadot-developers/polkadot-docs/issues/new?template=docs-issue.yml){target=\_blank}**. Your feedback makes the whole ecosystem better for everyone. + +## Support Channels Use one of the channels below to get live technical support or ask questions. -
- - Connect to Telegram - - - Connect to Discord - +
+ +- :simple-telegram:{ .sub } **Telegram: Polkadot Developer Support** + +
    +
  • **Who’s there:** DevRel team and active developer community.
  • +
  • **Response time:** Within **2 business days (usually faster)**.
  • +
  • **Topics:** Any developer-related question is welcome.
  • +
+ + πŸ‘‰ [Join Telegram](https://t.me/substratedevs){target=\_blank} + +- :simple-discord:{ .sub } **Discord: Polkadot Official Server** + +
    +
  • **Smart contracts:** Ask in `#solidity-smart-contracts` and `#ink_smart-contracts`.
  • +
  • **General developer support:** Ask in `#solidity-smart-contracts`.
  • +
  • **Response time:** Within **1 business day (usually faster)**.
  • +
+ + πŸ‘‰ [Join Discord](https://polkadot-discord.w3f.tools/){target=\_blank} + +- :simple-matrix:{ .sub } **Matrix: Polkadot Developer Support** + +
    +
  • **Who’s there:** Parity, W3F, DevRel, and community contributors.
  • +
  • **Response time:** Within **1 business day (usually faster)**.
  • +
  • **Topics:** Full-spectrum developer support.
  • +
  • Bridged with Telegram (all messages synced).
  • +
+ + πŸ‘‰ [Join Matrix](https://matrix.to/#/#substratedevs:matrix.org){target=\_blank} +
+## Community Resources + +
-## Need More than Just Documentation? +- :fontawesome-brands-stack-exchange:{ .sub } **Stack Exchange** + +
    +
  • Browse commonly asked technical questions.
  • +
  • Ask your own and get detailed responses from experienced devs.
  • +
-You're already in the docs β€” solid start. -But sometimes you need more: answers, real examples, someone to talk to. -This support hub is here to help you move forward β€” faster. + πŸ‘‰ [Visit Polkadot Stack Exchange](https://substrate.stackexchange.com/){target=\_blank} -Whether you're building something new, integrating into the ecosystem, or running into blockers β€” **don't stay stuck**. +- :simple-reddit:{ .sub } **Reddit: r/Polkadot** + +
    +
  • General discussions and community perspectives.
  • +
  • Developer questions are welcome β€” just tag them appropriately.
  • +
-## What You Can Do Here + πŸ‘‰ [Visit r/Polkadot](https://www.reddit.com/r/Polkadot/){target=\_blank} -- πŸ“¨ [**Get In Touch**](/get-support/get-in-touch/) - Reach out to the Polkadot support team and community via Telegram, Matrix, or Discord. - Ask technical questions, report blockers, or share feedback β€” and get a human response. +- :simple-youtube:{ .sub } **YouTube: @PolkadotNetwork** + +
    +
  • Developer tutorials.
  • +
  • Ecosystem interviews.
  • +
  • Event recordings and walkthroughs.
  • +
-- 🧠 [**Explore Available Resources**](/get-support/explore-resources/) - Find answers beyond the documentation: developer forums, Stack Exchange, Reddit, YouTube, governance hubs, and more. + πŸ‘‰ [Watch on YouTube](https://www.youtube.com/@PolkadotNetwork){target=\_blank} -This hub is evolving. More support tools and shortcuts are on the way, including enhanced onboarding, CLI helpers, development environments, and live feedback channels. +- :fontawesome-brands-x-twitter:{ .sub } **X (Twitter): Official Accounts** + + - **[@PolkadotDevs](https://x.com/PolkadotDevs){target=\_blank}**: Updates for developers. + - **[@Polkadot](https://x.com/Polkadot){target=\_blank}**: Network-wide news. + - **[@Kusamanetwork](https://x.com/kusamanetwork){target=\_blank}**: Kusama-specific updates. + - **[@Web3Foundation](https://x.com/web3foundation){target=\_blank}**: Grants, research, and ecosystem programs. -## Help Us Improve +- :fontawesome-brands-x-twitter:{ .sub } **X (Twitter): Community Accounts** -If something’s missing, unclear, or broken β€” **tell us**. -Your feedback makes the whole ecosystem better for everyone. + - **[@PolkadotDeploy](https://x.com/PolkadotDeploy){target=\_blank}**: News from the deployment portal and tooling updates. -πŸ‘‰ [**Get In Touch**](/get-support/get-in-touch/) and help shape the future of developer support. +- :material-forum:{ .sub } **Polkadot Forum** + +
    +
  • Join community discussions around the direction of the ecosystem.
  • +
+ + πŸ‘‰ [Visit the Polkadot Forum](https://forum.polkadot.network/){target=\_blank} + +- :material-vote:{ .sub } **Polkassembly: OpenGov** + +
    +
  • Explore and vote on governance proposals for Polkadot and Kusama.
  • +
  • Help shape the future of the network.
  • +
+ + πŸ‘‰ [Explore on Polkassembly](https://polkadot.polkassembly.io/){target=\_blank} + +
+ +## AI Resources + +
+ +- :fontawesome-solid-robot:{ .sub } **AI Ready Documentation** + + Access documentation structured and optimized for use with large language models (LLMs) and AI tools. These resources help build AI assistants, power code search, or enable custom tooling trained on Polkadot’s documentation. + + πŸ‘‰ [Access LLM Files](/get-support/ai-ready-docs/){target=\_blank} + +
diff --git a/.ai/pages/smart-contracts-connect.md b/.ai/pages/smart-contracts-connect.md index c792279e0..9fa336ab2 100644 --- a/.ai/pages/smart-contracts-connect.md +++ b/.ai/pages/smart-contracts-connect.md @@ -41,7 +41,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t Chain ID ```text - 420420422 + 420420417 ``` --- @@ -49,7 +49,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t RPC URL ```text - https://testnet-passet-hub-eth-rpc.polkadot.io + https://services.polkadothub-rpc.com/testnet ``` --- @@ -57,7 +57,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t Block explorer URL ```text - https://blockscout-passet-hub.parity-testnet.parity.io/ + https://polkadot.testnet.routescan.io/ ``` @@ -65,7 +65,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t You will need testnet tokens to perform transactions and engage with smart contracts on any chain. Here's how to obtain Paseo (PAS) tokens for testing purposes: -1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank}. If the desired network is not already selected, choose it from the Network drop-down. +1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank}. If the desired network is not already selected, choose it from the Network drop-down. 2. Copy your address linked to the TestNet and paste it into the designated field. diff --git a/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md b/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md index a73a721c8..18de6461d 100644 --- a/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md +++ b/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md @@ -165,7 +165,7 @@ const config: HardhatUserConfig = { polkadotTestNet: { type: "http", chainType: "l1", - url: 'http://127.0.0.1:8545', + url: 'https://services.polkadothub-rpc.com/testnet', accounts: [process.env.PRIVATE_KEY || ''], }, }, @@ -222,7 +222,7 @@ You should see output similar to: npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet WARNING: You are using Node.js 23.11.0 which is not supported by Hardhat. Please upgrade to 22.10.0 or a later LTS version (even major version number) - βœ” Confirm deploy to network polkadotTestNet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestNet (420420417)? … yes Hardhat Ignition πŸš€ Deploying [ StorageModule ] Batch #1 @@ -267,7 +267,7 @@ To interact with Polkadot Hub, you need to set up a [Public Client](https://viem import { createPublicClient, http, createWalletClient, custom } from 'viem' import 'viem/window'; -const transport = http('http://127.0.0.1:8545') // TODO: change to the paseo asset hub RPC URL when it's available +const transport = http('https://services.polkadothub-rpc.com/testnet') // Configure the Polkadot Testnet Hub chain export const polkadotTestnet = { @@ -281,7 +281,7 @@ export const polkadotTestnet = { }, rpcUrls: { default: { - http: ['http://127.0.0.1:8545'], // TODO: change to the paseo asset hub RPC URL + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const diff --git a/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat.md b/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat.md index a2c9917a8..3e06b5e3c 100644 --- a/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat.md +++ b/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat.md @@ -54,8 +54,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, @@ -144,7 +144,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   diff --git a/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat.md b/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat.md index 9ddeb8e53..f86eb5b8c 100644 --- a/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat.md +++ b/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat.md @@ -138,7 +138,7 @@ You are now ready to deploy the contract to your chosen network. This example de
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   diff --git a/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat.md b/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat.md index 419a1ca96..b015a2bc6 100644 --- a/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat.md +++ b/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat.md @@ -61,8 +61,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, diff --git a/.ai/pages/smart-contracts-dev-environments-hardhat.md b/.ai/pages/smart-contracts-dev-environments-hardhat.md index d7050ad8f..a7e30744a 100644 --- a/.ai/pages/smart-contracts-dev-environments-hardhat.md +++ b/.ai/pages/smart-contracts-dev-environments-hardhat.md @@ -83,14 +83,14 @@ To use Hardhat with Polkadot Hub, define the network configuration in your `hard import { vars } from 'hardhat/config'; const config: HardhatUserConfig = { - solidity: '0.8.28', - networks: { + solidity: '0.8.28', + networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, - accounts: [vars.get('PRIVATE_KEY')], + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, + accounts: [vars.get('PRIVATE_KEY')], }, - }, + }, }; export default config; diff --git a/.ai/pages/smart-contracts-explorers.md b/.ai/pages/smart-contracts-explorers.md index b2c33d863..741014b8e 100644 --- a/.ai/pages/smart-contracts-explorers.md +++ b/.ai/pages/smart-contracts-explorers.md @@ -28,10 +28,10 @@ The following block explorers are available for PolkaVM smart contracts, providi -### BlockScout -BlockScout is an open-source explorer platform with a user-friendly interface adapted for PolkaVM contracts. It excels at detailed contract analytics and provides developers with comprehensive API access. -- [Polkadot Hub TestNet BlockScout](https://blockscout-passet-hub.parity-testnet.parity.io/){target=\_blank} +### Routescan -![](/images/smart-contracts/explorers/explorers-01.webp) +Routescan delivers multi-chain explorer capabilities with specialized support for PolkaVM environments. + +- [Polkadot Hub TestNet Routescan](https://polkadot.testnet.routescan.io/){target=\_blank} diff --git a/.ai/pages/smart-contracts-faucet.md b/.ai/pages/smart-contracts-faucet.md index 65da79ac1..caee79677 100644 --- a/.ai/pages/smart-contracts-faucet.md +++ b/.ai/pages/smart-contracts-faucet.md @@ -19,13 +19,13 @@ Polkadot has a faucet that distributes free TestNet tokens to developers for tes ## Get Test Tokens -For Polkadot Hub TestNet, you can use the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank} to obtain test tokens. Here's how to do it: +For Polkadot Hub TestNet, you can use the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank} to obtain test tokens. Here's how to do it: -1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank}. If the desired network is not already selected, choose it from the **Network** drop-down. This example uses the Polkadot Hub TestNet. +1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank}. If the desired network is not already selected, choose it from the **Network** drop-down. This example uses the Polkadot Hub TestNet. 2. Copy your address linked to the TestNet and paste it into the designated field. 3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly. -![Polkadot Faucet](/images/smart-contracts/faucet/faucet-1.gif) +![Polkadot Faucet](/images/smart-contracts/faucet/faucet-01.gif) ## Things to Consider diff --git a/.ai/pages/smart-contracts-for-eth-devs-json-rpc-apis.md b/.ai/pages/smart-contracts-for-eth-devs-json-rpc-apis.md index 29ef4fe0e..10b817e31 100644 --- a/.ai/pages/smart-contracts-for-eth-devs-json-rpc-apis.md +++ b/.ai/pages/smart-contracts-for-eth-devs-json-rpc-apis.md @@ -14,7 +14,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -30,7 +30,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -53,7 +53,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -83,7 +83,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -111,7 +111,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -141,7 +141,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -169,7 +169,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -193,7 +193,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -219,7 +219,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -245,7 +245,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -270,7 +270,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -295,7 +295,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -321,7 +321,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -351,7 +351,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -379,7 +379,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -405,7 +405,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -430,7 +430,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -456,7 +456,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -482,7 +482,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -507,7 +507,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -532,7 +532,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -555,7 +555,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -587,7 +587,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -620,7 +620,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -643,7 +643,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -666,7 +666,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -689,7 +689,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -712,7 +712,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -735,7 +735,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -761,7 +761,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -787,7 +787,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -820,7 +820,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", diff --git a/.ai/pages/smart-contracts-integrations-wallets.md b/.ai/pages/smart-contracts-integrations-wallets.md index c1fabdefa..0d63eccc6 100644 --- a/.ai/pages/smart-contracts-integrations-wallets.md +++ b/.ai/pages/smart-contracts-integrations-wallets.md @@ -21,58 +21,29 @@ To get started with MetaMask, you need to install the [MetaMask extension](https For example, to connect to the Polkadot Hub TestNet via MetaMask, you need to follow these steps: -1. Open the MetaMask extension and click on the network icon to switch to the Polkadot Hub TestNet. +1. Open the MetaMask extension and click on the network dropdown to switch to the Polkadot Hub TestNet. ![](/images/smart-contracts/integrations/wallets/wallets-1.webp){: .browser-extension} -2. Click on the **Add a custom network** button. +2. Click on the **Custom** tab. ![](/images/smart-contracts/integrations/wallets/wallets-2.webp){: .browser-extension} -3. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\_blank} section for copy and paste parameters). +3. Click on the **Add a custom network** button. ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension} -4. Click on **Polkadot Hub TestNet** to switch the network. +4. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\_blank} section for copy and paste parameters). - ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension} - -The steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters. - -### SubWallet - -[SubWallet](https://www.subwallet.app/){target=\_blank} is a popular non-custodial wallet solution for Polkadot and Ethereum ecosystems. It offers seamless integration with Polkadot SDK-based networks while maintaining Ethereum compatibility, making the wallet an ideal choice for users and developers to interact with Polkadot Hub. - -SubWallet now fully supports the [Polkadot Hub TestNet](/smart-contracts/connect/){target=\_blank} where developers can deploy and interact with Ethereum-compatible, Solidity smart contracts. - -You can easily view and manage your Paseo native token (PAS) using the Ethereum RPC endpoint (Passet Hub EVM) or the Substrate node RPC endpoint (passet-hub). - -??? code "Polkadot Hub TestNet" - You can see support here for Polkadot Hub's TestNet. The **Passet Hub EVM** network uses an ETH RPC endpoint, and the **passet-hub** uses a Substrate endpoint. - The ETH RPC endpoint will let you send transactions that follow an ETH format, while the Substrate endpoint will follow a Substrate transaction format. - Note the PAS token, which is the native token of the Polkadot Hub TestNet. - - ![](/images/smart-contracts/integrations/wallets/subwallet-PAS.webp){: .browser-extension} - -To connect to Polkadot Hub TestNet using SubWallet, follow these steps: - -1. Install the [SubWallet browser extension](https://chromewebstore.google.com/detail/subwallet-polkadot-wallet/onhogfjeacnfoofkfgppdlbmlmnplgbn?hl=en){target=\_blank} and set up your wallet by following the on-screen instructions, or refer to our [step-by-step guide](https://docs.subwallet.app/main/extension-user-guide/getting-started/install-subwallet){target=\_blank} for assistance. - -2. After setting up your wallet, click the List icon at the top left corner of the extension window to open **Settings**. - - ![](/images/smart-contracts/integrations/wallets/subwallet-01.webp){: .browser-extension} - -3. Scroll down and select **Manage networks**. + ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension} - ![](/images/smart-contracts/integrations/wallets/subwallet-02.webp){: .browser-extension} +5. Click on **Polkadot Hub TestNet** to switch the network. -4. In the Manage network screen, either scroll down or type in the search bar to find the networks. Once done, enable the toggle next to the network name. + ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension} - ![](/images/smart-contracts/integrations/wallets/subwallet-03.webp){: .browser-extension} +The steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters. - You are now ready to use SubWallet to interact with [Polkadot Hub TestNet](/smart-contracts/connect/#networks-details){target=\_blank} seamlessly! -![](/images/smart-contracts/integrations/wallets/subwallet-04.webp){: .browser-extension} ### Talisman @@ -82,37 +53,28 @@ To use Talisman with Polkadot Hub TestNet: 1. Install the [Talisman extension](https://talisman.xyz/download){target=\_blank} and set up your wallet by following the on-screen instructions. -2. Once installed, click on the Talisman icon in your browser extensions and click on the **Settings** button. +2. Once installed, click on the Talisman icon in your browser extensions and click on the **More** button. ![](/images/smart-contracts/integrations/wallets/wallets-5.webp){: .browser-extension} -3. Click the button **All settings**. +3. Click the button **Manage Networks**. ![](/images/smart-contracts/integrations/wallets/wallets-6.webp){: .browser-extension} -4. Go to the **Networks & Tokens** section. +4. Click on the **+ Add network** button. ![](/images/smart-contracts/integrations/wallets/wallets-7.webp) -5. Click the **Manage networks** button. +5. Fill in the form with the required parameters and click the ave** button. ![](/images/smart-contracts/integrations/wallets/wallets-8.webp) -6. Click the **+ Add network** button. +6. After that, you will see the **Polkadot Hub TestNet** in the list. ![](/images/smart-contracts/integrations/wallets/wallets-9.webp) -7. Fill in the form with the required parameters and click the **Add network** button. - - ![](/images/smart-contracts/integrations/wallets/wallets-10.webp) - -8. After that, you can switch to the Polkadot Hub TestNet by clicking on the network icon and selecting **Polkadot Hub TestNet**. - - ![](/images/smart-contracts/integrations/wallets/wallets-11.webp) - After selecting the network, Talisman will automatically configure the necessary RPC URL and chain ID for you. You can now use Talisman to interact with the Polkadot Hub TestNet. - ## Conclusion Choosing the right wallet for Polkadot Hub interactions depends on your specific requirements and familiarity with different interfaces. MetaMask provides a familiar entry point for developers with Ethereum experience, while Talisman offers deeper integration with Polkadot's unique features and native support for both EVM and Substrate accounts. By properly configuring your wallet connection, you gain access to the full spectrum of Polkadot Hub's capabilities. diff --git a/.ai/pages/smart-contracts-libraries-ethers-js.md b/.ai/pages/smart-contracts-libraries-ethers-js.md index a12b531a0..23a45d73c 100644 --- a/.ai/pages/smart-contracts-libraries-ethers-js.md +++ b/.ai/pages/smart-contracts-libraries-ethers-js.md @@ -108,8 +108,8 @@ createProvider(PROVIDER_RPC.rpc, PROVIDER_RPC.chainId, PROVIDER_RPC.name); ```js const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet' }; ``` @@ -137,8 +137,8 @@ With the provider set up, you can start querying the blockchain. For instance, t }; const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -402,8 +402,8 @@ You can create a `deploy.js` script in the root of your project to achieve this. ```js title="scripts/deploy.js" const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -504,8 +504,8 @@ You can create a `deploy.js` script in the root of your project to achieve this. }; const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; @@ -595,9 +595,9 @@ const interactWithStorageContract = async ( }; const providerConfig = { - name: 'asset-hub-smart-contracts', - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + name: 'polkadot-hub', + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, }; const mnemonic = 'INSERT_MNEMONIC' diff --git a/.ai/pages/smart-contracts-libraries-viem.md b/.ai/pages/smart-contracts-libraries-viem.md index 58d0dc87c..9e2b767bc 100644 --- a/.ai/pages/smart-contracts-libraries-viem.md +++ b/.ai/pages/smart-contracts-libraries-viem.md @@ -160,11 +160,11 @@ After setting up the [Public Client](https://viem.sh/docs/clients/public#public- ```js title="src/fetchLastBlock.ts" import { createPublicClient, http } from 'viem'; - const transport = http('https://testnet-passet-hub-eth-rpc.polkadot.io'); // TODO: change to paseo asset hub once ready + const transport = http('https://services.polkadothub-rpc.com/testnet'); // Configure the Polkadot Hub chain const polkadotHubTestnet = { - id: 420420422, + id: 420420417, name: 'Polkadot Hub TestNet', network: 'polkadot-hub-testnet', nativeCurrency: { @@ -174,7 +174,7 @@ After setting up the [Public Client](https://viem.sh/docs/clients/public#public- }, rpcUrls: { default: { - http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const; diff --git a/.ai/pages/smart-contracts-libraries-wagmi.md b/.ai/pages/smart-contracts-libraries-wagmi.md index 24c537f49..4238520ed 100644 --- a/.ai/pages/smart-contracts-libraries-wagmi.md +++ b/.ai/pages/smart-contracts-libraries-wagmi.md @@ -70,7 +70,7 @@ export const config = createConfig({ // Configure the Polkadot Hub chain const assetHub = { - id: 420420422, + id: 420420417, name: 'polkadot-hub-testnet', network: 'polkadot-hub-testnet', nativeCurrency: { @@ -80,7 +80,7 @@ export const config = createConfig({ }, rpcUrls: { default: { - http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const; diff --git a/.ai/pages/smart-contracts-libraries-web3-js.md b/.ai/pages/smart-contracts-libraries-web3-js.md index dd576e49a..b139fbe0a 100644 --- a/.ai/pages/smart-contracts-libraries-web3-js.md +++ b/.ai/pages/smart-contracts-libraries-web3-js.md @@ -102,8 +102,8 @@ createProvider(PROVIDER_RPC.rpc); ```js const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet' }; ``` @@ -127,8 +127,8 @@ With the provider set up, you can start querying the blockchain. For instance, t }; const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -390,8 +390,8 @@ You can create a `deploy.js` script in the `scripts` directory of your project t ```js title="scripts/deploy.js" const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -498,8 +498,8 @@ You can create a `deploy.js` script in the `scripts` directory of your project t }; const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; @@ -580,7 +580,7 @@ const updateStorage = async (config) => { }; const config = { - rpcUrl: 'https://testnet-passet-hub-eth-rpc.polkadot.io', + rpcUrl: 'https://services.polkadothub-rpc.com/testnet', privateKey: 'INSERT_PRIVATE_KEY', contractAddress: 'INSERT_CONTRACT_ADDRESS', }; diff --git a/.ai/pages/smart-contracts-libraries-web3-py.md b/.ai/pages/smart-contracts-libraries-web3-py.md index e4abbd767..5c54dab79 100644 --- a/.ai/pages/smart-contracts-libraries-web3-py.md +++ b/.ai/pages/smart-contracts-libraries-web3-py.md @@ -53,7 +53,7 @@ web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC)) Replace `INSERT_RPC_URL` with the appropriate value. For instance, to connect to Polkadot Hub TestNet, use the following parameter: ```python - PROVIDER_RPC = 'https://testnet-passet-hub-eth-rpc.polkadot.io' + PROVIDER_RPC = 'https://services.polkadothub-rpc.com/testnet' ``` With the Web3 provider set up, start querying the blockchain. For instance, you can use the following code snippet to fetch the latest block number of the chain. @@ -66,7 +66,7 @@ With the Web3 provider set up, start querying the blockchain. For instance, you def main(): try: - PROVIDER_RPC = "https://testnet-passet-hub-eth-rpc.polkadot.io" + PROVIDER_RPC = "https://services.polkadothub-rpc.com/testnet" web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC)) latest_block = web3.eth.block_number print("Last block: " + str(latest_block)) diff --git a/.ai/site-index.json b/.ai/site-index.json index 7fa1090d1..16cf62fb2 100644 --- a/.ai/site-index.json +++ b/.ai/site-index.json @@ -17,129 +17,17 @@ }, { "depth": 2, - "title": "Download LLM Files", - "anchor": "download-llm-files" + "title": "Access LLM Files", + "anchor": "access-llm-files" } ], "stats": { - "chars": 7998, + "chars": 7996, "words": 825, "headings": 2, "estimated_token_count_total": 2232 }, - "hash": "sha256:5a8da69a5cea8bd598ee4d102b9abed5d1a29153802a567e22bb4ee720410b32", - "token_estimator": "heuristic-v1" - }, - { - "id": "get-support-explore-resources", - "title": "Subscribe to Updates", - "slug": "get-support-explore-resources", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-explore-resources.md", - "html_url": "https://docs.polkadot.com/get-support/explore-resources/", - "preview": "Looking for answers beyond the documentation? These platforms are full of useful content and experienced developers sharing insights.", - "outline": [ - { - "depth": 2, - "title": "🧠 Stack Exchange", - "anchor": "stack-exchange" - }, - { - "depth": 2, - "title": "🧡 Reddit: r/Polkadot", - "anchor": "reddit-rpolkadot" - }, - { - "depth": 2, - "title": "πŸ’¬ Discord (Community Threads Only)", - "anchor": "discord-community-threads-only" - }, - { - "depth": 2, - "title": "πŸŽ₯ YouTube: @PolkadotNetwork", - "anchor": "youtube-polkadotnetwork" - }, - { - "depth": 2, - "title": "Community-Led Platforms and Ecosystem Updates", - "anchor": "community-led-platforms-and-ecosystem-updates" - }, - { - "depth": 3, - "title": "πŸ”· X (Twitter): Official Accounts", - "anchor": "x-twitter-official-accounts" - }, - { - "depth": 3, - "title": "πŸ” X (Twitter): Community Accounts", - "anchor": "x-twitter-community-accounts" - }, - { - "depth": 3, - "title": "πŸ—£οΈ Polkadot Forum", - "anchor": "polkadot-forum" - }, - { - "depth": 3, - "title": "πŸ§‘β€βš–οΈ Polkassembly: OpenGov", - "anchor": "polkassembly-opengov" - }, - { - "depth": 3, - "title": "πŸ“Έ Instagram", - "anchor": "instagram" - } - ], - "stats": { - "chars": 2426, - "words": 295, - "headings": 10, - "estimated_token_count_total": 579 - }, - "hash": "sha256:670221ac20ab1f1b550ba2a1db06cd924c24bd3afc4d8a768b617d8a409243cb", - "token_estimator": "heuristic-v1" - }, - { - "id": "get-support-get-in-touch", - "title": "Get in Touch", - "slug": "get-support-get-in-touch", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-get-in-touch.md", - "html_url": "https://docs.polkadot.com/get-support/get-in-touch/", - "preview": "Use one of the channels below to get live technical support or ask questions.", - "outline": [ - { - "depth": 2, - "title": "Need Help Fast?", - "anchor": "need-help-fast" - }, - { - "depth": 2, - "title": "πŸ“± Telegram: Polkadot Developer Support", - "anchor": "telegram-polkadot-developer-support" - }, - { - "depth": 2, - "title": "πŸ”Œ Discord: Polkadot Official Server", - "anchor": "discord-polkadot-official-server" - }, - { - "depth": 2, - "title": "🧬 Matrix: Polkadot Developer Support", - "anchor": "matrix-polkadot-developer-support" - } - ], - "stats": { - "chars": 1949, - "words": 258, - "headings": 4, - "estimated_token_count_total": 557 - }, - "hash": "sha256:993e93b05c8fbdfc2f7510c61ac86bc4c2ff0f03e573695b2f260933c8b62f78", + "hash": "sha256:1aa997c6fecf9ff5f6b2fde718c928518d6697bb818f71aa391fbb38a1946ff4", "token_estimator": "heuristic-v1" }, { @@ -151,31 +39,31 @@ ], "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support.md", "html_url": "https://docs.polkadot.com/get-support/", - "preview": "Use one of the channels below to get live technical support or ask questions.", + "preview": "You're already in the docs β€” solid start. But sometimes you need more: answers, real examples, someone to talk to. This support hub is here to help you move forward β€” faster.", "outline": [ { "depth": 2, - "title": "Need More than Just Documentation?", - "anchor": "need-more-than-just-documentation" + "title": "Support Channels", + "anchor": "support-channels" }, { "depth": 2, - "title": "What You Can Do Here", - "anchor": "what-you-can-do-here" + "title": "Community Resources", + "anchor": "community-resources" }, { "depth": 2, - "title": "Help Us Improve", - "anchor": "help-us-improve" + "title": "AI Resources", + "anchor": "ai-resources" } ], "stats": { - "chars": 1658, - "words": 244, + "chars": 4621, + "words": 579, "headings": 3, - "estimated_token_count_total": 280 + "estimated_token_count_total": 1223 }, - "hash": "sha256:5bdc575ac798a971867a15651c2b4d5139bf0b1fe6854d1865deff280ae6d7f6", + "hash": "sha256:69e5bcd8ec2f35e39ff674b7f709c7526dd34427ddd66d449ecb01d29a405321", "token_estimator": "heuristic-v1" }, { @@ -6308,12 +6196,12 @@ } ], "stats": { - "chars": 3502, - "words": 488, + "chars": 3468, + "words": 481, "headings": 3, - "estimated_token_count_total": 623 + "estimated_token_count_total": 609 }, - "hash": "sha256:302a3aeed61fdf8c23f07676ef5faf7b5af9ccca406b9bc6820c7dedeac96600", + "hash": "sha256:f546392ad577e0f4038f5fed10414ec9ab457deffb2e1c56c19a22d13b438d04", "token_estimator": "heuristic-v1" }, { @@ -6440,12 +6328,12 @@ } ], "stats": { - "chars": 31211, - "words": 3687, + "chars": 31166, + "words": 3665, "headings": 22, - "estimated_token_count_total": 6967 + "estimated_token_count_total": 6938 }, - "hash": "sha256:7601883deaf979854d5b08a13d2119ce2a6c1c6d3b6158d823e86da580a19722", + "hash": "sha256:e6ef23e520129c8c7521de3cfdf261991e2feb10429797d8308f170f116cd7f4", "token_estimator": "heuristic-v1" }, { @@ -6755,12 +6643,12 @@ } ], "stats": { - "chars": 5979, - "words": 795, + "chars": 5977, + "words": 793, "headings": 8, - "estimated_token_count_total": 1476 + "estimated_token_count_total": 1472 }, - "hash": "sha256:16a5788a6935cb86da1e18be7929e413e74811c57dbab06de4fa4048c752e508", + "hash": "sha256:eac3464009cc775ebc7405fbe6b0ba6c931c263c94ea3f6104c234a98f93aadb", "token_estimator": "heuristic-v1" }, { @@ -6873,7 +6761,7 @@ "headings": 8, "estimated_token_count_total": 1964 }, - "hash": "sha256:19b1f0953c1333eaee44165be25e549189c21acb624ddf4ab11bd989bfcde7ef", + "hash": "sha256:b991f2b4dbb0e34bbf2f57e79ecefe360abfb4224f8cbe911c6a67702b289e97", "token_estimator": "heuristic-v1" }, { @@ -7049,12 +6937,12 @@ } ], "stats": { - "chars": 7377, - "words": 972, + "chars": 7375, + "words": 970, "headings": 8, - "estimated_token_count_total": 1844 + "estimated_token_count_total": 1840 }, - "hash": "sha256:4bb4fcee01cd8203d4e382ca2ec2a45eb9ef86a531d3bb8b61b7286d10917129", + "hash": "sha256:9a7d1c8e9bc42dad6357335f07a91786f628c9e615945c60d215eff182801923", "token_estimator": "heuristic-v1" }, { @@ -7186,12 +7074,12 @@ } ], "stats": { - "chars": 4828, - "words": 646, + "chars": 4838, + "words": 644, "headings": 5, - "estimated_token_count_total": 1144 + "estimated_token_count_total": 1140 }, - "hash": "sha256:7911b91e6c8dc9caa7403756d92d6aa78438c45ebf42088dbdcbefd3d396e6ee", + "hash": "sha256:45538095463b6edd3c461774771751226abac06886b5933d9997240ff91a0281", "token_estimator": "heuristic-v1" }, { @@ -7311,17 +7199,17 @@ }, { "depth": 3, - "title": "BlockScout", - "anchor": "blockscout" + "title": "Routescan", + "anchor": "routescan" } ], "stats": { - "chars": 1618, - "words": 201, + "chars": 1442, + "words": 174, "headings": 4, - "estimated_token_count_total": 307 + "estimated_token_count_total": 263 }, - "hash": "sha256:bb41c42439f9076628abf553347a1cd46557e900f73554c519cd8a075f6e14e2", + "hash": "sha256:1f401a2aef16cd120ceb6ddc575cbfc19ea0ce985a6d045825aefc54e456dddc", "token_estimator": "heuristic-v1" }, { @@ -7352,12 +7240,12 @@ } ], "stats": { - "chars": 1890, - "words": 279, + "chars": 1861, + "words": 275, "headings": 3, - "estimated_token_count_total": 313 + "estimated_token_count_total": 305 }, - "hash": "sha256:c609bc98cba5efa2d2a808548cf93ad9d0a06455b35a8fd9f534daf52824f506", + "hash": "sha256:f66362afa44ba90cabc6d28a169e3df7f0d045123c0ea3a29570a33db3b8f064", "token_estimator": "heuristic-v1" }, { @@ -7953,12 +7841,12 @@ } ], "stats": { - "chars": 31274, - "words": 3827, + "chars": 31210, + "words": 3763, "headings": 35, - "estimated_token_count_total": 9562 + "estimated_token_count_total": 9434 }, - "hash": "sha256:ef851649797d7a65de72c2390495dba0c449ce254135bb96dea3ff82d8835148", + "hash": "sha256:63eb49ba8dc71fa07d161a87787d79b36f26d9854d1030282cda490a4ed753f2", "token_estimator": "heuristic-v1" }, { @@ -8085,11 +7973,6 @@ "title": "MetaMask", "anchor": "metamask" }, - { - "depth": 3, - "title": "SubWallet", - "anchor": "subwallet" - }, { "depth": 3, "title": "Talisman", @@ -8102,12 +7985,12 @@ } ], "stats": { - "chars": 7131, - "words": 1015, - "headings": 6, - "estimated_token_count_total": 1617 + "chars": 4417, + "words": 629, + "headings": 5, + "estimated_token_count_total": 975 }, - "hash": "sha256:ef59012ff4338bc606910c173299130e93f4e47e1fc9c9d9e99e0d5dd0d66e9e", + "hash": "sha256:94aa482d3b91711a3a5246120649f1d0c831e1353de96ce8f04793b22e90a0d7", "token_estimator": "heuristic-v1" }, { @@ -8184,12 +8067,12 @@ } ], "stats": { - "chars": 21292, - "words": 2412, + "chars": 21115, + "words": 2378, "headings": 12, - "estimated_token_count_total": 4742 + "estimated_token_count_total": 4672 }, - "hash": "sha256:3493aaeec569be8d72f418c9b1abeeed64ff3bbcc316b42a33dad5f172c4e841", + "hash": "sha256:8245452657e900455ae4a9cc8da74c07d49b2b28fca10827b82ec0d7306c0e9f", "token_estimator": "heuristic-v1" }, { @@ -8276,12 +8159,12 @@ } ], "stats": { - "chars": 17416, - "words": 2000, + "chars": 17320, + "words": 1980, "headings": 14, - "estimated_token_count_total": 4151 + "estimated_token_count_total": 4121 }, - "hash": "sha256:dc93c1418e6cfc56ea714a2105b8ba82d72f9888a022feb356c1847fbb913b54", + "hash": "sha256:e31c9182aee0369c64d3c6ba3ec20f45379360ba692dc0f9358d5a22eb841711", "token_estimator": "heuristic-v1" }, { @@ -8348,12 +8231,12 @@ } ], "stats": { - "chars": 13435, - "words": 1499, + "chars": 13387, + "words": 1489, "headings": 10, - "estimated_token_count_total": 3258 + "estimated_token_count_total": 3243 }, - "hash": "sha256:99916a667b468415b029bd745edfa23716e23dfc7cd313921a1bb0ea3378f644", + "hash": "sha256:ffe8afac7a4724c125a9520e0fc2ddc28e5fd4666ce9edce6eaffddeccc70ba0", "token_estimator": "heuristic-v1" }, { @@ -8430,12 +8313,12 @@ } ], "stats": { - "chars": 20077, - "words": 2252, + "chars": 19911, + "words": 2220, "headings": 12, - "estimated_token_count_total": 4530 + "estimated_token_count_total": 4464 }, - "hash": "sha256:7e3d9a39fafd48ef71f23b07d20f7fb5572ba67e06fcbe6a199fe0468af6dbca", + "hash": "sha256:236c1f97eab1bdab9d65ca308634fdeec75fdb2ee02a5e6b78789228f84dda1b", "token_estimator": "heuristic-v1" }, { @@ -8497,12 +8380,12 @@ } ], "stats": { - "chars": 14097, - "words": 1665, + "chars": 14093, + "words": 1661, "headings": 9, - "estimated_token_count_total": 2987 + "estimated_token_count_total": 2979 }, - "hash": "sha256:22e632b20dd4e0459bcd93ed7984b270642e5d8ec2267623be91b63fe3023c75", + "hash": "sha256:cc9f7ae91578eb82243752ec5d5fae34905a6252170cff47d59688426e77d536", "token_estimator": "heuristic-v1" }, { diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html index d7738ff9e..4d4277bc5 100644 --- a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html @@ -1,6 +1,6 @@
npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/hardhat.config.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/hardhat.config.ts index 039124fdf..087b6de1d 100644 --- a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/hardhat.config.ts +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/hardhat.config.ts @@ -17,8 +17,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html index 5a29c3a74..461299fa3 100644 --- a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html @@ -1,6 +1,6 @@
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes   Hardhat Ignition πŸš€   diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/hardhat.config.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/hardhat.config.ts index 055cae4b5..d6929753a 100644 --- a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/hardhat.config.ts +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/hardhat.config.ts @@ -16,8 +16,8 @@ const config: HardhatUserConfig = { }, networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, accounts: [vars.get('PRIVATE_KEY')], }, }, diff --git a/.snippets/code/smart-contracts/libraries/ethers-js/checkStorage.js b/.snippets/code/smart-contracts/libraries/ethers-js/checkStorage.js index 8febb14e5..b0bb34b63 100644 --- a/.snippets/code/smart-contracts/libraries/ethers-js/checkStorage.js +++ b/.snippets/code/smart-contracts/libraries/ethers-js/checkStorage.js @@ -66,9 +66,9 @@ const interactWithStorageContract = async ( }; const providerConfig = { - name: 'asset-hub-smart-contracts', - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + name: 'polkadot-hub', + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, }; const mnemonic = 'INSERT_MNEMONIC' diff --git a/.snippets/code/smart-contracts/libraries/ethers-js/deploy.js b/.snippets/code/smart-contracts/libraries/ethers-js/deploy.js index c753c714a..f99f4266b 100644 --- a/.snippets/code/smart-contracts/libraries/ethers-js/deploy.js +++ b/.snippets/code/smart-contracts/libraries/ethers-js/deploy.js @@ -82,8 +82,8 @@ const deployContract = async (contractName, mnemonic, providerConfig) => { }; const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; diff --git a/.snippets/code/smart-contracts/libraries/ethers-js/fetchLastBlock.js b/.snippets/code/smart-contracts/libraries/ethers-js/fetchLastBlock.js index fda1c4831..3f04db0b2 100644 --- a/.snippets/code/smart-contracts/libraries/ethers-js/fetchLastBlock.js +++ b/.snippets/code/smart-contracts/libraries/ethers-js/fetchLastBlock.js @@ -10,8 +10,8 @@ const createProvider = (rpcUrl, chainId, chainName) => { }; const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet', }; diff --git a/.snippets/code/smart-contracts/libraries/viem/fetchLastBlock.ts b/.snippets/code/smart-contracts/libraries/viem/fetchLastBlock.ts index b24073ea7..4d8407b97 100644 --- a/.snippets/code/smart-contracts/libraries/viem/fetchLastBlock.ts +++ b/.snippets/code/smart-contracts/libraries/viem/fetchLastBlock.ts @@ -1,10 +1,10 @@ import { createPublicClient, http } from 'viem'; -const transport = http('https://testnet-passet-hub-eth-rpc.polkadot.io'); // TODO: change to paseo asset hub once ready +const transport = http('https://services.polkadothub-rpc.com/testnet'); // Configure the Polkadot Hub chain const polkadotHubTestnet = { - id: 420420422, + id: 420420417, name: 'Polkadot Hub TestNet', network: 'polkadot-hub-testnet', nativeCurrency: { @@ -14,7 +14,7 @@ const polkadotHubTestnet = { }, rpcUrls: { default: { - http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const; diff --git a/.snippets/code/smart-contracts/libraries/wagmi/wagmi-testnet.ts b/.snippets/code/smart-contracts/libraries/wagmi/wagmi-testnet.ts index ec9354be8..fd5fa3e5e 100644 --- a/.snippets/code/smart-contracts/libraries/wagmi/wagmi-testnet.ts +++ b/.snippets/code/smart-contracts/libraries/wagmi/wagmi-testnet.ts @@ -2,7 +2,7 @@ import { http, createConfig } from 'wagmi'; // Configure the Polkadot Hub chain const assetHub = { - id: 420420422, + id: 420420417, name: 'polkadot-hub-testnet', network: 'polkadot-hub-testnet', nativeCurrency: { @@ -12,7 +12,7 @@ const assetHub = { }, rpcUrls: { default: { - http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const; diff --git a/.snippets/code/smart-contracts/libraries/web3-js/deploy.js b/.snippets/code/smart-contracts/libraries/web3-js/deploy.js index f36a8eb55..1bdc3715d 100644 --- a/.snippets/code/smart-contracts/libraries/web3-js/deploy.js +++ b/.snippets/code/smart-contracts/libraries/web3-js/deploy.js @@ -87,8 +87,8 @@ const deployContract = async (contractName, privateKey, providerConfig) => { }; const providerConfig = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; diff --git a/.snippets/code/smart-contracts/libraries/web3-js/fetchLastBlock.js b/.snippets/code/smart-contracts/libraries/web3-js/fetchLastBlock.js index bcbe863bf..245a840e0 100644 --- a/.snippets/code/smart-contracts/libraries/web3-js/fetchLastBlock.js +++ b/.snippets/code/smart-contracts/libraries/web3-js/fetchLastBlock.js @@ -6,8 +6,8 @@ const createProvider = (rpcUrl) => { }; const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadotTestNet', }; diff --git a/.snippets/code/smart-contracts/libraries/web3-js/updateStorage.js b/.snippets/code/smart-contracts/libraries/web3-js/updateStorage.js index 6fff61593..aaa8557cb 100644 --- a/.snippets/code/smart-contracts/libraries/web3-js/updateStorage.js +++ b/.snippets/code/smart-contracts/libraries/web3-js/updateStorage.js @@ -55,7 +55,7 @@ const updateStorage = async (config) => { }; const config = { - rpcUrl: 'https://testnet-passet-hub-eth-rpc.polkadot.io', + rpcUrl: 'https://services.polkadothub-rpc.com/testnet', privateKey: 'INSERT_PRIVATE_KEY', contractAddress: 'INSERT_CONTRACT_ADDRESS', }; diff --git a/.snippets/code/smart-contracts/libraries/web3-py/fetch_last_block.py b/.snippets/code/smart-contracts/libraries/web3-py/fetch_last_block.py index c5fe6ea48..8ddd92c60 100644 --- a/.snippets/code/smart-contracts/libraries/web3-py/fetch_last_block.py +++ b/.snippets/code/smart-contracts/libraries/web3-py/fetch_last_block.py @@ -3,7 +3,7 @@ def main(): try: - PROVIDER_RPC = "https://testnet-passet-hub-eth-rpc.polkadot.io" + PROVIDER_RPC = "https://services.polkadothub-rpc.com/testnet" web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC)) latest_block = web3.eth.block_number print("Last block: " + str(latest_block)) diff --git a/images/smart-contracts/connect/connect-to-polkadot-01.webp b/images/smart-contracts/connect/connect-to-polkadot-01.webp index 62552aa17..ffc0d22df 100644 Binary files a/images/smart-contracts/connect/connect-to-polkadot-01.webp and b/images/smart-contracts/connect/connect-to-polkadot-01.webp differ diff --git a/images/smart-contracts/connect/connect-to-polkadot-02.webp b/images/smart-contracts/connect/connect-to-polkadot-02.webp index c7dcde0f8..d7716ac31 100644 Binary files a/images/smart-contracts/connect/connect-to-polkadot-02.webp and b/images/smart-contracts/connect/connect-to-polkadot-02.webp differ diff --git a/images/smart-contracts/faucet/faucet-01.gif b/images/smart-contracts/faucet/faucet-01.gif new file mode 100644 index 000000000..dd9fb3da7 Binary files /dev/null and b/images/smart-contracts/faucet/faucet-01.gif differ diff --git a/images/smart-contracts/faucet/faucet-1.gif b/images/smart-contracts/faucet/faucet-1.gif deleted file mode 100644 index 79e5bbc01..000000000 Binary files a/images/smart-contracts/faucet/faucet-1.gif and /dev/null differ diff --git a/images/smart-contracts/integrations/wallets/wallets-1.webp b/images/smart-contracts/integrations/wallets/wallets-1.webp index b8b14d31a..78ccafa73 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-1.webp and b/images/smart-contracts/integrations/wallets/wallets-1.webp differ diff --git a/images/smart-contracts/integrations/wallets/wallets-10.webp b/images/smart-contracts/integrations/wallets/wallets-10.webp deleted file mode 100644 index 629162e03..000000000 Binary files a/images/smart-contracts/integrations/wallets/wallets-10.webp and /dev/null differ diff --git a/images/smart-contracts/integrations/wallets/wallets-11.webp b/images/smart-contracts/integrations/wallets/wallets-11.webp deleted file mode 100644 index 23ad25ca6..000000000 Binary files a/images/smart-contracts/integrations/wallets/wallets-11.webp and /dev/null differ diff --git a/images/smart-contracts/integrations/wallets/wallets-2.webp b/images/smart-contracts/integrations/wallets/wallets-2.webp index f1bd79b8b..5f576bafa 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-2.webp and b/images/smart-contracts/integrations/wallets/wallets-2.webp differ diff --git a/images/smart-contracts/integrations/wallets/wallets-3.webp b/images/smart-contracts/integrations/wallets/wallets-3.webp index 235e7028f..fa9234b70 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-3.webp and b/images/smart-contracts/integrations/wallets/wallets-3.webp differ diff --git a/images/smart-contracts/integrations/wallets/wallets-4.webp b/images/smart-contracts/integrations/wallets/wallets-4.webp index bdd175a11..d64acfb57 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-4.webp and b/images/smart-contracts/integrations/wallets/wallets-4.webp differ diff --git a/images/smart-contracts/integrations/wallets/wallets-5.webp b/images/smart-contracts/integrations/wallets/wallets-5.webp index f31e8f9ab..02d6e03d0 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-5.webp and b/images/smart-contracts/integrations/wallets/wallets-5.webp differ diff --git a/images/smart-contracts/integrations/wallets/wallets-6.webp b/images/smart-contracts/integrations/wallets/wallets-6.webp index ee5368781..86a3cff74 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-6.webp and b/images/smart-contracts/integrations/wallets/wallets-6.webp differ diff --git a/images/smart-contracts/integrations/wallets/wallets-7.webp b/images/smart-contracts/integrations/wallets/wallets-7.webp index bc7006a81..dee9e5474 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-7.webp and b/images/smart-contracts/integrations/wallets/wallets-7.webp differ diff --git a/images/smart-contracts/integrations/wallets/wallets-8.webp b/images/smart-contracts/integrations/wallets/wallets-8.webp index b33a65f2b..10fa7a2ab 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-8.webp and b/images/smart-contracts/integrations/wallets/wallets-8.webp differ diff --git a/images/smart-contracts/integrations/wallets/wallets-9.webp b/images/smart-contracts/integrations/wallets/wallets-9.webp index 6e5475e5c..9191852d8 100644 Binary files a/images/smart-contracts/integrations/wallets/wallets-9.webp and b/images/smart-contracts/integrations/wallets/wallets-9.webp differ diff --git a/llms-full.jsonl b/llms-full.jsonl index c3f3e930a..f8f197373 100644 --- a/llms-full.jsonl +++ b/llms-full.jsonl @@ -1,22 +1,8 @@ {"page_id": "get-support-ai-ready-docs", "page_title": "AI Ready Docs", "index": 0, "depth": 2, "title": "How to Use These Files", "anchor": "how-to-use-these-files", "start_char": 286, "end_char": 952, "estimated_token_count": 164, "token_estimator": "heuristic-v1", "text": "## How to Use These Files\n\n- **Quick navigation**: Use `llms.txt` to give models a high-level map of the site.\n- **Lightweight context**: Use `site-index.json` for smaller context windows or when you only need targeted retrieval.\n- **Full content**: Use `llms-full.jsonl` for large-context models or preparing data for RAG pipelines.\n- **Focused bundles**: Use category files (e.g., `basics.md`, `parachains.md`) to limit content to a specific theme or task for more focused responses.\n\nThese AI-ready files do not include any persona or system prompts. They are purely informational and can be used without conflicting with your existing agent or tool prompting."} -{"page_id": "get-support-ai-ready-docs", "page_title": "AI Ready Docs", "index": 1, "depth": 2, "title": "Download LLM Files", "anchor": "download-llm-files", "start_char": 952, "end_char": 7998, "estimated_token_count": 2068, "token_estimator": "heuristic-v1", "text": "## Download LLM Files\n\n| Category | Description | File | Actions |\n|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Index | Markdown URL index for documentation pages, links to essential repos, and additional resources in the llms.txt standard format. | llms.txt |
[:octicons-copy-16:](){ .llms-copy data-path=\"/llms.txt\" } [:octicons-download-16:](){ .llms-dl data-path=\"/llms.txt\" data-filename=\"llms.txt\" }
|\n| Site index (JSON) | Lightweight site index of JSON objects (one per page) with metadata and content previews. | site-index.json |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/site-index.json\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/site-index.json\" data-filename=\"site-index.json\" }
|\n| Full site contents (JSONL) | Full content of documentation site enhanced with metadata. | llms-full.jsonl |
[:octicons-copy-16:](){ .llms-copy data-path=\"/llms-full.jsonl\" } [:octicons-download-16:](){ .llms-dl data-path=\"/llms-full.jsonl\" data-filename=\"llms-full.jsonl\" }
|\n| Basics | Polkadot general knowledge base to provide context around overview and beginner-level content. | basics.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/basics.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/basics.md\" data-filename=\"basics.md\" }
|\n| Reference | Reference material including key functions and glossary. | reference.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/reference.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/reference.md\" data-filename=\"reference.md\" }
|\n| Smart Contracts | How to develop and deploy Solidity smart contracts on Polkadot Hub. | smart-contracts.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/smart-contracts.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/smart-contracts.md\" data-filename=\"smart-contracts.md\" }
|\n| Parachains | How-to guides related to building, customizing, deploying, and maintaining a parachain. | parachains.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/parachains.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/parachains.md\" data-filename=\"parachains.md\" }
|\n| DApps | Information and tutorials for application developers. | dapps.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/dapps.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/dapps.md\" data-filename=\"dapps.md\" }
|\n| Networks | Information about the various Polkadot networks (Polkadot, Kusama, Westend, Paseo), their purposes, and how they fit into the development workflow. | networks.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/networks.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/networks.md\" data-filename=\"networks.md\" }
|\n| Polkadot Protocol | Polkadot's core architecture, including the relay chain, parachains, system chains, interoperability, and main actors. | polkadot-protocol.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/polkadot-protocol.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/polkadot-protocol.md\" data-filename=\"polkadot-protocol.md\" }
|\n| Infrastructure | Operational aspects of supporting the Polkadot network, including how to run a node or validator and staking mechanics. | infrastructure.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/infrastructure.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/infrastructure.md\" data-filename=\"infrastructure.md\" }
|\n| Tooling | An overview of various development tools available for Polkadot development. | tooling.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/tooling.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/tooling.md\" data-filename=\"tooling.md\" }
|\n\n!!! note\n The `llms-full.jsonl` file may exceed the input limits of some language models due to its size. If you encounter limitations, consider using the smaller `site-index.json` or category bundle files instead."} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 0, "depth": 2, "title": "🧠 Stack Exchange", "anchor": "stack-exchange", "start_char": 178, "end_char": 403, "estimated_token_count": 53, "token_estimator": "heuristic-v1", "text": "## 🧠 Stack Exchange\n\n- Browse commonly asked technical questions.\n- Ask your own and get detailed responses from experienced devs.\n\nπŸ‘‰ **[Visit Polkadot Stack Exchange](https://substrate.stackexchange.com/){target=\\_blank}**"} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 1, "depth": 2, "title": "🧡 Reddit: r/Polkadot", "anchor": "reddit-rpolkadot", "start_char": 403, "end_char": 631, "estimated_token_count": 60, "token_estimator": "heuristic-v1", "text": "## 🧡 Reddit: r/Polkadot\n\n- General Polkadot discussions and community perspectives.\n- Developer questions are welcome β€” just tag them appropriately.\n\nπŸ‘‰ **[Visit r/Polkadot](https://www.reddit.com/r/Polkadot/){target=\\_blank}**"} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 2, "depth": 2, "title": "πŸ’¬ Discord (Community Threads Only)", "anchor": "discord-community-threads-only", "start_char": 631, "end_char": 900, "estimated_token_count": 66, "token_estimator": "heuristic-v1", "text": "## πŸ’¬ Discord (Community Threads Only)\n\n- Beyond the official support threads, most channels are community-driven.\n- Great place to connect with fellow builders and share insights.\n\nπŸ‘‰ **[Join the Polkadot Discord](https://polkadot-discord.w3f.tools/){target=\\_blank}**"} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 3, "depth": 2, "title": "πŸŽ₯ YouTube: @PolkadotNetwork", "anchor": "youtube-polkadotnetwork", "start_char": 900, "end_char": 1098, "estimated_token_count": 48, "token_estimator": "heuristic-v1", "text": "## πŸŽ₯ YouTube: @PolkadotNetwork\n\n- Developer tutorials\n- Ecosystem interviews\n- Event recordings and walkthroughs\n\nπŸ‘‰ **[Watch on YouTube](https://www.youtube.com/@PolkadotNetwork){target=\\_blank}**"} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 4, "depth": 2, "title": "Community-Led Platforms and Ecosystem Updates", "anchor": "community-led-platforms-and-ecosystem-updates", "start_char": 1098, "end_char": 1298, "estimated_token_count": 34, "token_estimator": "heuristic-v1", "text": "## Community-Led Platforms and Ecosystem Updates\n\nStay in sync with what's happening across the Polkadot ecosystem β€” from official announcements to community-driven insights and governance activity."} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 5, "depth": 3, "title": "πŸ”· X (Twitter): Official Accounts", "anchor": "x-twitter-official-accounts", "start_char": 1298, "end_char": 1693, "estimated_token_count": 121, "token_estimator": "heuristic-v1", "text": "### πŸ”· X (Twitter): Official Accounts\n\n- [@PolkadotDevs](https://x.com/PolkadotDevs){target=\\_blank}: Updates for developers\n- [@Polkadot](https://x.com/Polkadot){target=\\_blank}: Network-wide news\n- [@Kusamanetwork](https://x.com/kusamanetwork){target=\\_blank}: Kusama-specific updates\n- [@Web3Foundation](https://x.com/web3foundation){target=\\_blank}: Grants, research, and ecosystem programs"} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 6, "depth": 3, "title": "πŸ” X (Twitter): Community Accounts", "anchor": "x-twitter-community-accounts", "start_char": 1693, "end_char": 1852, "estimated_token_count": 42, "token_estimator": "heuristic-v1", "text": "### πŸ” X (Twitter): Community Accounts\n\n- [@PolkadotDeploy](https://x.com/PolkadotDeploy){target=\\_blank}: News from the deployment portal and tooling updates"} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 7, "depth": 3, "title": "πŸ—£οΈ Polkadot Forum", "anchor": "polkadot-forum", "start_char": 1852, "end_char": 2027, "estimated_token_count": 47, "token_estimator": "heuristic-v1", "text": "### πŸ—£οΈ Polkadot Forum\n\n- Join community discussions around the direction of the ecosystem.\n\nπŸ‘‰ **[Visit the Polkadot Forum](https://forum.polkadot.network/){target=\\_blank}**"} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 8, "depth": 3, "title": "πŸ§‘β€βš–οΈ Polkassembly: OpenGov", "anchor": "polkassembly-opengov", "start_char": 2027, "end_char": 2252, "estimated_token_count": 59, "token_estimator": "heuristic-v1", "text": "### πŸ§‘β€βš–οΈ Polkassembly: OpenGov\n\n- Explore and vote on governance proposals for Polkadot and Kusama.\n- Help shape the future of the network.\n\nπŸ‘‰ **[Explore on Polkassembly](https://polkadot.polkassembly.io/){target=\\_blank}**"} -{"page_id": "get-support-explore-resources", "page_title": "Subscribe to Updates", "index": 9, "depth": 3, "title": "πŸ“Έ Instagram", "anchor": "instagram", "start_char": 2252, "end_char": 2426, "estimated_token_count": 49, "token_estimator": "heuristic-v1", "text": "### πŸ“Έ Instagram\n\n- **[@Polkadotnetwork](https://www.instagram.com/polkadotnetwork){target=\\_blank}**: Visual highlights from the ecosystem\n _(Note: not developer-specific)_"} -{"page_id": "get-support-get-in-touch", "page_title": "Get in Touch", "index": 0, "depth": 2, "title": "Need Help Fast?", "anchor": "need-help-fast", "start_char": 25, "end_char": 546, "estimated_token_count": 152, "token_estimator": "heuristic-v1", "text": "## Need Help Fast?\n \nUse one of the channels below to get live technical support or ask questions.\n\n\n\nPrefer to see all available channels? Below are your options."} -{"page_id": "get-support-get-in-touch", "page_title": "Get in Touch", "index": 1, "depth": 2, "title": "πŸ“± Telegram: Polkadot Developer Support", "anchor": "telegram-polkadot-developer-support", "start_char": 546, "end_char": 876, "estimated_token_count": 94, "token_estimator": "heuristic-v1", "text": "## πŸ“± Telegram: Polkadot Developer Support\n\nThe fastest way to get support.\n\n- **Who’s there:** DevRel team and active developer community.\n- **Response time:** Within **2 business days (usually faster)**.\n- **Topics:** Any developer-related question is welcome.\n\nπŸ‘‰ **[Join Telegram](https://t.me/substratedevs){target=\\_blank}**"} -{"page_id": "get-support-get-in-touch", "page_title": "Get in Touch", "index": 2, "depth": 2, "title": "πŸ”Œ Discord: Polkadot Official Server", "anchor": "discord-polkadot-official-server", "start_char": 876, "end_char": 1328, "estimated_token_count": 128, "token_estimator": "heuristic-v1", "text": "## πŸ”Œ Discord: Polkadot Official Server\n\nFocused support for smart contracts and general developer chat.\n\n- **Smart contracts:** Ask in `#solidity-smart-contracts` and `#ink_smart-contracts`.\n- **General developer support:** Ask in `#solidity-smart-contracts`.\n- **Response time:** Within **1 business day (usually faster)**.\n- **Other topics:** Community-led discussion only.\n\nπŸ‘‰ **[Join Discord](https://polkadot-discord.w3f.tools/){target=\\_blank}**"} -{"page_id": "get-support-get-in-touch", "page_title": "Get in Touch", "index": 3, "depth": 2, "title": "🧬 Matrix: Polkadot Developer Support", "anchor": "matrix-polkadot-developer-support", "start_char": 1328, "end_char": 1949, "estimated_token_count": 183, "token_estimator": "heuristic-v1", "text": "## 🧬 Matrix: Polkadot Developer Support\n\nThis is the **support channel** staffed by engineers from **Parity**, **Web3 Foundation**, and **Polkadot DevRel**.\n\n- **Who’s there:** Parity, W3F, DevRel, and community contributors.\n- **Response time:** Within **1 business day (usually faster)**.\n- **Topics:** Full-spectrum developer support.\n- Bridged with Telegram (all messages synced).\n\nπŸ‘‰ **[Join Matrix](https://matrix.to/#/#substratedevs:matrix.org){target=\\_blank}**\n\n---\n\nNot sure where to start? \n\n**Join [Telegram](#telegram-polkadot-developer-support)**: Let us know what you need, and we’ll help you get unstuck."} -{"page_id": "get-support", "page_title": "Support", "index": 0, "depth": 2, "title": "Need More than Just Documentation?", "anchor": "need-more-than-just-documentation", "start_char": 456, "end_char": 796, "estimated_token_count": 76, "token_estimator": "heuristic-v1", "text": "## Need More than Just Documentation?\n\nYou're already in the docs β€” solid start. \nBut sometimes you need more: answers, real examples, someone to talk to. \nThis support hub is here to help you move forward β€” faster.\n\nWhether you're building something new, integrating into the ecosystem, or running into blockers β€” **don't stay stuck**."} -{"page_id": "get-support", "page_title": "Support", "index": 1, "depth": 2, "title": "What You Can Do Here", "anchor": "what-you-can-do-here", "start_char": 796, "end_char": 1419, "estimated_token_count": 139, "token_estimator": "heuristic-v1", "text": "## What You Can Do Here\n\n- πŸ“¨ [**Get In Touch**](/get-support/get-in-touch/) \n Reach out to the Polkadot support team and community via Telegram, Matrix, or Discord. \n Ask technical questions, report blockers, or share feedback β€” and get a human response.\n\n- 🧠 [**Explore Available Resources**](/get-support/explore-resources/) \n Find answers beyond the documentation: developer forums, Stack Exchange, Reddit, YouTube, governance hubs, and more.\n\nThis hub is evolving. More support tools and shortcuts are on the way, including enhanced onboarding, CLI helpers, development environments, and live feedback channels."} -{"page_id": "get-support", "page_title": "Support", "index": 2, "depth": 2, "title": "Help Us Improve", "anchor": "help-us-improve", "start_char": 1419, "end_char": 1658, "estimated_token_count": 65, "token_estimator": "heuristic-v1", "text": "## Help Us Improve\n\nIf something’s missing, unclear, or broken β€” **tell us**. \nYour feedback makes the whole ecosystem better for everyone.\n\nπŸ‘‰ [**Get In Touch**](/get-support/get-in-touch/) and help shape the future of developer support."} +{"page_id": "get-support-ai-ready-docs", "page_title": "AI Ready Docs", "index": 1, "depth": 2, "title": "Access LLM Files", "anchor": "access-llm-files", "start_char": 952, "end_char": 7996, "estimated_token_count": 2068, "token_estimator": "heuristic-v1", "text": "## Access LLM Files\n\n| Category | Description | File | Actions |\n|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Index | Markdown URL index for documentation pages, links to essential repos, and additional resources in the llms.txt standard format. | llms.txt |
[:octicons-copy-16:](){ .llms-copy data-path=\"/llms.txt\" } [:octicons-download-16:](){ .llms-dl data-path=\"/llms.txt\" data-filename=\"llms.txt\" }
|\n| Site index (JSON) | Lightweight site index of JSON objects (one per page) with metadata and content previews. | site-index.json |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/site-index.json\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/site-index.json\" data-filename=\"site-index.json\" }
|\n| Full site contents (JSONL) | Full content of documentation site enhanced with metadata. | llms-full.jsonl |
[:octicons-copy-16:](){ .llms-copy data-path=\"/llms-full.jsonl\" } [:octicons-download-16:](){ .llms-dl data-path=\"/llms-full.jsonl\" data-filename=\"llms-full.jsonl\" }
|\n| Basics | Polkadot general knowledge base to provide context around overview and beginner-level content. | basics.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/basics.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/basics.md\" data-filename=\"basics.md\" }
|\n| Reference | Reference material including key functions and glossary. | reference.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/reference.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/reference.md\" data-filename=\"reference.md\" }
|\n| Smart Contracts | How to develop and deploy Solidity smart contracts on Polkadot Hub. | smart-contracts.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/smart-contracts.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/smart-contracts.md\" data-filename=\"smart-contracts.md\" }
|\n| Parachains | How-to guides related to building, customizing, deploying, and maintaining a parachain. | parachains.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/parachains.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/parachains.md\" data-filename=\"parachains.md\" }
|\n| DApps | Information and tutorials for application developers. | dapps.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/dapps.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/dapps.md\" data-filename=\"dapps.md\" }
|\n| Networks | Information about the various Polkadot networks (Polkadot, Kusama, Westend, Paseo), their purposes, and how they fit into the development workflow. | networks.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/networks.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/networks.md\" data-filename=\"networks.md\" }
|\n| Polkadot Protocol | Polkadot's core architecture, including the relay chain, parachains, system chains, interoperability, and main actors. | polkadot-protocol.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/polkadot-protocol.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/polkadot-protocol.md\" data-filename=\"polkadot-protocol.md\" }
|\n| Infrastructure | Operational aspects of supporting the Polkadot network, including how to run a node or validator and staking mechanics. | infrastructure.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/infrastructure.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/infrastructure.md\" data-filename=\"infrastructure.md\" }
|\n| Tooling | An overview of various development tools available for Polkadot development. | tooling.md |
[:octicons-copy-16:](){ .llms-copy data-path=\"/ai/categories/tooling.md\" } [:octicons-download-16:](){ .llms-dl data-path=\"/ai/categories/tooling.md\" data-filename=\"tooling.md\" }
|\n\n!!! note\n The `llms-full.jsonl` file may exceed the input limits of some language models due to its size. If you encounter limitations, consider using the smaller `site-index.json` or category bundle files instead."} +{"page_id": "get-support", "page_title": "Support", "index": 0, "depth": 2, "title": "Support Channels", "anchor": "support-channels", "start_char": 433, "end_char": 1896, "estimated_token_count": 453, "token_estimator": "heuristic-v1", "text": "## Support Channels\n\nUse one of the channels below to get live technical support or ask questions.\n\n
\n\n- :simple-telegram:{ .sub } **Telegram: Polkadot Developer Support**\n\n
    \n
  • **Who’s there:** DevRel team and active developer community.
  • \n
  • **Response time:** Within **2 business days (usually faster)**.
  • \n
  • **Topics:** Any developer-related question is welcome.
  • \n
\n\n πŸ‘‰ [Join Telegram](https://t.me/substratedevs){target=\\_blank}\n\n- :simple-discord:{ .sub } **Discord: Polkadot Official Server**\n \n
    \n
  • **Smart contracts:** Ask in `#solidity-smart-contracts` and `#ink_smart-contracts`.
  • \n
  • **General developer support:** Ask in `#solidity-smart-contracts`.
  • \n
  • **Response time:** Within **1 business day (usually faster)**.
  • \n
\n\n πŸ‘‰ [Join Discord](https://polkadot-discord.w3f.tools/){target=\\_blank}\n\n- :simple-matrix:{ .sub } **Matrix: Polkadot Developer Support**\n\n
    \n
  • **Who’s there:** Parity, W3F, DevRel, and community contributors.
  • \n
  • **Response time:** Within **1 business day (usually faster)**.
  • \n
  • **Topics:** Full-spectrum developer support.
  • \n
  • Bridged with Telegram (all messages synced).
  • \n
\n\n πŸ‘‰ [Join Matrix](https://matrix.to/#/#substratedevs:matrix.org){target=\\_blank}\n\n
"} +{"page_id": "get-support", "page_title": "Support", "index": 1, "depth": 2, "title": "Community Resources", "anchor": "community-resources", "start_char": 1896, "end_char": 4187, "estimated_token_count": 667, "token_estimator": "heuristic-v1", "text": "## Community Resources\n\n
\n\n- :fontawesome-brands-stack-exchange:{ .sub } **Stack Exchange**\n \n
    \n
  • Browse commonly asked technical questions.
  • \n
  • Ask your own and get detailed responses from experienced devs.
  • \n
\n\n πŸ‘‰ [Visit Polkadot Stack Exchange](https://substrate.stackexchange.com/){target=\\_blank}\n\n- :simple-reddit:{ .sub } **Reddit: r/Polkadot**\n \n
    \n
  • General discussions and community perspectives.
  • \n
  • Developer questions are welcome β€” just tag them appropriately.
  • \n
\n\n πŸ‘‰ [Visit r/Polkadot](https://www.reddit.com/r/Polkadot/){target=\\_blank}\n\n- :simple-youtube:{ .sub } **YouTube: @PolkadotNetwork**\n \n
    \n
  • Developer tutorials.
  • \n
  • Ecosystem interviews.
  • \n
  • Event recordings and walkthroughs.
  • \n
\n\n πŸ‘‰ [Watch on YouTube](https://www.youtube.com/@PolkadotNetwork){target=\\_blank}\n\n- :fontawesome-brands-x-twitter:{ .sub } **X (Twitter): Official Accounts**\n \n - **[@PolkadotDevs](https://x.com/PolkadotDevs){target=\\_blank}**: Updates for developers.\n - **[@Polkadot](https://x.com/Polkadot){target=\\_blank}**: Network-wide news.\n - **[@Kusamanetwork](https://x.com/kusamanetwork){target=\\_blank}**: Kusama-specific updates.\n - **[@Web3Foundation](https://x.com/web3foundation){target=\\_blank}**: Grants, research, and ecosystem programs.\n\n- :fontawesome-brands-x-twitter:{ .sub } **X (Twitter): Community Accounts**\n\n - **[@PolkadotDeploy](https://x.com/PolkadotDeploy){target=\\_blank}**: News from the deployment portal and tooling updates.\n\n- :material-forum:{ .sub } **Polkadot Forum**\n \n
    \n
  • Join community discussions around the direction of the ecosystem.
  • \n
\n\n πŸ‘‰ [Visit the Polkadot Forum](https://forum.polkadot.network/){target=\\_blank}\n\n- :material-vote:{ .sub } **Polkassembly: OpenGov**\n \n
    \n
  • Explore and vote on governance proposals for Polkadot and Kusama.
  • \n
  • Help shape the future of the network.
  • \n
\n\n πŸ‘‰ [Explore on Polkassembly](https://polkadot.polkassembly.io/){target=\\_blank}\n\n
"} +{"page_id": "get-support", "page_title": "Support", "index": 2, "depth": 2, "title": "AI Resources", "anchor": "ai-resources", "start_char": 4187, "end_char": 4621, "estimated_token_count": 103, "token_estimator": "heuristic-v1", "text": "## AI Resources\n\n
\n\n- :fontawesome-solid-robot:{ .sub } **AI Ready Documentation**\n\n Access documentation structured and optimized for use with large language models (LLMs) and AI tools. These resources help build AI assistants, power code search, or enable custom tooling trained on Polkadot’s documentation.\n\n πŸ‘‰ [Access LLM Files](/get-support/ai-ready-docs/){target=\\_blank}\n\n
"} {"page_id": "node-infrastructure-run-a-collator", "page_title": "Run a Block-Producing Collator", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 34, "end_char": 1172, "estimated_token_count": 209, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nBlock-producing collators are the backbone of system parachain operations. Unlike RPC or archive nodes, which maintain state, collators actively produce blocks and submit them to relay chain validators for inclusion. They ensure network liveness, censorship resistance, and cross-chain message processing.\n\nCollators maintain fully synced relay chain and parachain nodes, aggregate transactions into blocks, create parachain block candidates, generate state transition proofs (Proof-of-Validity), and send block candidates to relay chain validators. They also enable cross-chain message handling via XCM. While critical for liveness, collators do not secure the networkβ€”security is provided by relay chain validators through the [ELVES protocol](https://wiki.polkadot.com/learn/learn-parachains-protocol/){target=\\_blank}.\n\nThis guide explains how to set up a collator for Polkadot system parachains, covering all key requirements, setting up and registering session keys, and meeting governance approval or invulnerables-list criteria (required for system parachains; non-system parachains may be more permissionless)."} {"page_id": "node-infrastructure-run-a-collator", "page_title": "Run a Block-Producing Collator", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 1172, "end_char": 1190, "estimated_token_count": 3, "token_estimator": "heuristic-v1", "text": "## Prerequisites"} {"page_id": "node-infrastructure-run-a-collator", "page_title": "Run a Block-Producing Collator", "index": 2, "depth": 3, "title": "Hardware Requirements", "anchor": "hardware-requirements", "start_char": 1190, "end_char": 1902, "estimated_token_count": 155, "token_estimator": "heuristic-v1", "text": "### Hardware Requirements\n\nBlock-producing collators require robust hardware for reliable operation, including the following:\n\n- **CPU**: 4+ cores (8+ cores recommended for optimal performance)\n- **Memory**: 32 GB RAM minimum (64 GB recommended)\n- **Storage**:\n - 200+ GB NVMe SSD (with pruning enabled for both parachain and relay chain)\n - Fast disk I/O is critical for block production performance\n- **Network**:\n - Public IP address\n - 100+ Mbps connection; a stable connection is critical\n - Open ports:\n - **30333**: Parachain P2P\n - **30334**: Relay chain P2P\n\n!!! warning \"Uptime is critical\"\n Consider redundancy and monitoring to maintain block production reliability."} @@ -872,31 +858,31 @@ {"page_id": "reference", "page_title": "Technical Reference Overview", "index": 4, "depth": 2, "title": "Glossary", "anchor": "glossary", "start_char": 4593, "end_char": 5034, "estimated_token_count": 90, "token_estimator": "heuristic-v1", "text": "## Glossary\n\nThe [Glossary](/reference/glossary/){target=\\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include:\n\n- Blockchain concepts (blocks, transactions, state)\n- Consensus mechanisms (validators, collators, finality)\n- Polkadot-specific terms (relay chain, parachain, XCM, FRAME)\n- Network components (nodes, runtimes, storage)\n- Governance terminology (origins, tracks, referendums)"} {"page_id": "reference", "page_title": "Technical Reference Overview", "index": 5, "depth": 2, "title": "Tools", "anchor": "tools", "start_char": 5034, "end_char": 6301, "estimated_token_count": 349, "token_estimator": "heuristic-v1", "text": "## Tools\n\nThe [Tools](/reference/tools/){target=\\_blank} section documents essential development and interaction tools for the Polkadot ecosystem:\n\n- **Light clients**: Lightweight solutions for interacting with the network without running full nodes.\n- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\\_blank} and [PAPI](/reference/tools/papi/){target=\\_blank} for building applications.\n- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\\_blank} and other Rust-based libraries for SDK development.\n- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\\_blank} for Python developers.\n- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\\_blank}, and [Omninode](/reference/tools/omninode/){target=\\_blank} for smart contract and parachain testing.\n- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\\_blank} for substrate interaction.\n- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\\_blank} for XCM integration and asset transfers."} {"page_id": "reference", "page_title": "Technical Reference Overview", "index": 6, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6301, "end_char": 7664, "estimated_token_count": 334, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nFor detailed exploration of specific areas, proceed to any of the main sections:\n\n
\n\n- Learn **Polkadot Hub**\n\n ---\n\n Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance.\n\n [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/)\n\n- Learn **Parachains**\n\n ---\n\n Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains.\n\n [:octicons-arrow-right-24: Reference](/reference/parachains/)\n\n- Learn **On-Chain Governance**\n\n ---\n\n Explore Polkadot's decentralized governance framework and how to participate in network decision-making.\n\n [:octicons-arrow-right-24: Reference](/reference/governance/)\n\n- Guide **Glossary**\n\n ---\n\n Quick reference for Polkadot-specific terminology and concepts used throughout the documentation.\n\n [:octicons-arrow-right-24: Reference](/reference/glossary/)\n\n- Guide **Tools**\n\n ---\n\n Discover development tools, libraries, and frameworks for building and interacting with Polkadot.\n\n [:octicons-arrow-right-24: Reference](/reference/tools/)\n\n
"} -{"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 0, "depth": 2, "title": "Networks Details", "anchor": "networks-details", "start_char": 771, "end_char": 1424, "estimated_token_count": 137, "token_estimator": "heuristic-v1", "text": "## Networks Details\n\nDevelopers can leverage smart contracts across diverse networks, from TestNets to MainNet. This section outlines the network specifications and connection details for each environment.\n\n=== \"Polkadot Hub TestNet\"\n\n Network name\n\n ```text\n Polkadot Hub TestNet\n ```\n\n ---\n\n Currency symbol\n \n ```text\n PAS\n ```\n\n ---\n \n Chain ID\n \n ```text\n 420420422\n ```\n\n ---\n \n RPC URL\n \n ```text\n https://testnet-passet-hub-eth-rpc.polkadot.io\n ```\n\n ---\n \n Block explorer URL\n \n ```text\n https://blockscout-passet-hub.parity-testnet.parity.io/\n ```"} -{"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 1, "depth": 2, "title": "Test Tokens", "anchor": "test-tokens", "start_char": 1424, "end_char": 2438, "estimated_token_count": 233, "token_estimator": "heuristic-v1", "text": "## Test Tokens\n\nYou will need testnet tokens to perform transactions and engage with smart contracts on any chain. Here's how to obtain Paseo (PAS) tokens for testing purposes:\n\n1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\\_blank}. If the desired network is not already selected, choose it from the Network drop-down.\n\n2. Copy your address linked to the TestNet and paste it into the designated field.\n\n ![](/images/smart-contracts/connect/connect-to-polkadot-01.webp)\n\n3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly.\n\n ![](/images/smart-contracts/connect/connect-to-polkadot-02.webp)\n\nNow that you have obtained PAS tokens in your wallet, you’re ready to deploy and interact with smart contracts on Polkadot Hub TestNet! These tokens will allow you to pay for gas fees when executing transactions, deploying contracts, and testing your dApp functionality in a secure testnet environment."} -{"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 2, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 2438, "end_char": 3502, "estimated_token_count": 253, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nFor your next steps, explore the various smart contract guides demonstrating how to use and integrate different tools and development environments into your workflow.\n\n
\n\n- Guide __Get started with Remix__\n\n ---\n\n Learn how to get started with Remix, a browser-based IDE for writing, deploying, and interacting with smart contracts.\n\n [:octicons-arrow-right-24: Build with Remix IDE](/smart-contracts/dev-environments/remix/)\n\n- Guide __Deploy a contract using Remix__\n\n ---\n\n Deploy your first contract on Polkadot Hub using the Remix IDE.\n\n [:octicons-arrow-right-24: Build with Remix IDE](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix/)\n\n- Guide __Interact with the blockchain with viem__\n\n ---\n\n Use viem to deploy and interact with smart contracts on Polkadot Hub.\n\n [:octicons-arrow-right-24: Build with viem](/smart-contracts/libraries/viem/)\n\n
"} +{"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 0, "depth": 2, "title": "Networks Details", "anchor": "networks-details", "start_char": 771, "end_char": 1405, "estimated_token_count": 127, "token_estimator": "heuristic-v1", "text": "## Networks Details\n\nDevelopers can leverage smart contracts across diverse networks, from TestNets to MainNet. This section outlines the network specifications and connection details for each environment.\n\n=== \"Polkadot Hub TestNet\"\n\n Network name\n\n ```text\n Polkadot Hub TestNet\n ```\n\n ---\n\n Currency symbol\n \n ```text\n PAS\n ```\n\n ---\n \n Chain ID\n \n ```text\n 420420417\n ```\n\n ---\n \n RPC URL\n \n ```text\n https://services.polkadothub-rpc.com/testnet\n ```\n\n ---\n \n Block explorer URL\n \n ```text\n https://polkadot.testnet.routescan.io/\n ```"} +{"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 1, "depth": 2, "title": "Test Tokens", "anchor": "test-tokens", "start_char": 1405, "end_char": 2404, "estimated_token_count": 229, "token_estimator": "heuristic-v1", "text": "## Test Tokens\n\nYou will need testnet tokens to perform transactions and engage with smart contracts on any chain. Here's how to obtain Paseo (PAS) tokens for testing purposes:\n\n1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/){target=\\_blank}. If the desired network is not already selected, choose it from the Network drop-down.\n\n2. Copy your address linked to the TestNet and paste it into the designated field.\n\n ![](/images/smart-contracts/connect/connect-to-polkadot-01.webp)\n\n3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly.\n\n ![](/images/smart-contracts/connect/connect-to-polkadot-02.webp)\n\nNow that you have obtained PAS tokens in your wallet, you’re ready to deploy and interact with smart contracts on Polkadot Hub TestNet! These tokens will allow you to pay for gas fees when executing transactions, deploying contracts, and testing your dApp functionality in a secure testnet environment."} +{"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 2, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 2404, "end_char": 3468, "estimated_token_count": 253, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nFor your next steps, explore the various smart contract guides demonstrating how to use and integrate different tools and development environments into your workflow.\n\n
\n\n- Guide __Get started with Remix__\n\n ---\n\n Learn how to get started with Remix, a browser-based IDE for writing, deploying, and interacting with smart contracts.\n\n [:octicons-arrow-right-24: Build with Remix IDE](/smart-contracts/dev-environments/remix/)\n\n- Guide __Deploy a contract using Remix__\n\n ---\n\n Deploy your first contract on Polkadot Hub using the Remix IDE.\n\n [:octicons-arrow-right-24: Build with Remix IDE](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix/)\n\n- Guide __Interact with the blockchain with viem__\n\n ---\n\n Use viem to deploy and interact with smart contracts on Polkadot Hub.\n\n [:octicons-arrow-right-24: Build with viem](/smart-contracts/libraries/viem/)\n\n
"} {"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 0, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 787, "end_char": 1258, "estimated_token_count": 113, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore getting started, ensure you have the following:\n\n- [Node.js](https://nodejs.org/en){target=\\_blank} v22.10.0 or later installed on your system.\n- A crypto wallet (such as MetaMask) funded with test tokens. Refer to the [Connect to Polkadot](/smart-contracts/connect){target=\\_blank} guide for more details.\n- A basic understanding of React and JavaScript.\n- Some familiarity with blockchain fundamentals and Solidity (helpful but not required)."} {"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 1, "depth": 2, "title": "Project Overview", "anchor": "project-overview", "start_char": 1258, "end_char": 2446, "estimated_token_count": 296, "token_estimator": "heuristic-v1", "text": "## Project Overview\n\nThis dApp will interact with a basic Storage contract that you will create and deploy with Hardhat. The contract will allow you to:\n\n- Store a number on the blockchain.\n- Retrieve the stored number from the blockchain.\n- Update the stored number with a new value.\n\nYour project directory will be organized as follows:\n\n```bash\npolkadot-hub-tutorial/\nβ”œβ”€β”€ storage-contract/ # Hardhat project for smart contract\nβ”‚ β”œβ”€β”€ contracts/\nβ”‚ β”‚ └── Storage.sol\nβ”‚ β”œβ”€β”€ scripts/\nβ”‚ β”‚ └── deploy.ts\nβ”‚ β”œβ”€β”€ artifacts/\nβ”‚ β”‚ └── contracts/\nβ”‚ β”‚ └── Storage.sol/\nβ”‚ β”‚ └── Storage.json\nβ”‚ β”œβ”€β”€ hardhat.config.ts\nβ”‚ β”œβ”€β”€ .env\nβ”‚ └── package.json\nβ”‚\n└── dapp/ # Next.js dApp project\n β”œβ”€β”€ abis/\n β”‚ └── Storage.json\n └── app/\n β”œβ”€β”€ components/\n β”‚ β”œβ”€β”€ ReadContract.tsx\n β”‚ β”œβ”€β”€ WalletConnect.tsx\n β”‚ └── WriteContract.tsx\n β”œβ”€β”€ utils/\n β”‚ β”œβ”€β”€ contract.ts\n β”‚ └── viem.ts\n β”œβ”€β”€ favicon.ico\n β”œβ”€β”€ globals.css\n β”œβ”€β”€ layout.tsx\n └── page.tsx\n```\n\nCreate the main folder for the project:\n\n```bash\nmkdir polkadot-hub-tutorial\ncd polkadot-hub-tutorial\n```"} {"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 2, "depth": 2, "title": "Create and Deploy the Storage Contract", "anchor": "create-and-deploy-the-storage-contract", "start_char": 2446, "end_char": 2695, "estimated_token_count": 48, "token_estimator": "heuristic-v1", "text": "## Create and Deploy the Storage Contract\n\nBefore building the dApp, you'll need to create and deploy the Storage smart contract. This section will guide you through using Hardhat to write, compile, and deploy the contract to Polkadot Hub TestNet."} {"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 3, "depth": 3, "title": "Set Up Hardhat Project", "anchor": "set-up-hardhat-project", "start_char": 2695, "end_char": 3094, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "### Set Up Hardhat Project\n\nFirst, create a new directory for your Hardhat project and initialize it:\n\n```bash\nmkdir storage-contract\ncd storage-contract\nnpm init -y\n```\n\nInstall Hardhat and its dependencies:\n\n```bash\nnpm install --save-dev hardhat@3.0.9\n```\n\nInitialize a new Hardhat project:\n\n```bash\nnpx hardhat --init\n```\n\nSelect **Create a TypeScript project** and accept the default options."} {"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 4, "depth": 3, "title": "Create the Storage Contract", "anchor": "create-the-storage-contract", "start_char": 3094, "end_char": 3633, "estimated_token_count": 112, "token_estimator": "heuristic-v1", "text": "### Create the Storage Contract\n\nIn the `contracts` directory, create a new file called `Storage.sol` and add the following code:\n\n```solidity title=\"Storage.sol\"\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract Storage {\n uint256 private storedNumber;\n\n event NumberStored(uint256 newNumber);\n\n function setNumber(uint256 _number) public {\n storedNumber = _number;\n emit NumberStored(_number);\n }\n}\n```\n\nThis simple contract stores a single number and provides functions to read and update it."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 5, "depth": 3, "title": "Configure Hardhat for Polkadot Hub", "anchor": "configure-hardhat-for-polkadot-hub", "start_char": 3633, "end_char": 5430, "estimated_token_count": 415, "token_estimator": "heuristic-v1", "text": "### Configure Hardhat for Polkadot Hub\n\nUpdate your `hardhat.config.ts` file to include the Polkadot Hub TestNet configuration:\n\n```typescript title=\"hardhat.config.ts\" hl_lines=\"39-44\"\nimport type { HardhatUserConfig } from \"hardhat/config\";\n\nimport hardhatToolboxViemPlugin from \"@nomicfoundation/hardhat-toolbox-viem\";\nimport { configVariable } from \"hardhat/config\";\n\nconst config: HardhatUserConfig = {\n plugins: [hardhatToolboxViemPlugin],\n solidity: {\n profiles: {\n default: {\n version: \"0.8.28\",\n },\n production: {\n version: \"0.8.28\",\n settings: {\n optimizer: {\n enabled: true,\n runs: 200,\n },\n },\n },\n },\n },\n networks: {\n hardhatMainnet: {\n type: \"edr-simulated\",\n chainType: \"l1\",\n },\n hardhatOp: {\n type: \"edr-simulated\",\n chainType: \"op\",\n },\n sepolia: {\n type: \"http\",\n chainType: \"l1\",\n url: configVariable(\"SEPOLIA_RPC_URL\"),\n accounts: [configVariable(\"SEPOLIA_PRIVATE_KEY\")],\n },\n polkadotTestNet: {\n type: \"http\",\n chainType: \"l1\",\n url: 'http://127.0.0.1:8545',\n accounts: [process.env.PRIVATE_KEY || ''],\n },\n },\n};\n\nexport default config;\n```\n\nCreate a `.env` file in the root of your Hardhat project:\n\n```text title=\".env\"\nPRIVATE_KEY=INSERT_PRIVATE_KEY_HERE\n```\n\nReplace `INSERT_PRIVATE_KEY_HERE` with your actual private key. You can get this by exporting the private key from your wallet (e.g., MetaMask).\n\n!!! warning\n Never commit your private key to version control. Use environment variables or a `.env` file (and add it to `.gitignore`) to manage sensitive information. Keep your private key safe, and never share it with anyone. If it is compromised, your funds can be stolen."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 6, "depth": 3, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 5430, "end_char": 5579, "estimated_token_count": 29, "token_estimator": "heuristic-v1", "text": "### Compile the Contract\n\nCompile your Storage contract:\n\n```bash\nnpx hardhat compile\n```\n\nYou should see output indicating successful compilation."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 7, "depth": 3, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 5579, "end_char": 7216, "estimated_token_count": 416, "token_estimator": "heuristic-v1", "text": "### Deploy the Contract\n\nCreate a deployment script in the `ignition/modules` directory called `Storage.ts`:\n\n```typescript title=\"Storage.ts\"\nimport { buildModule } from \"@nomicfoundation/hardhat-ignition/modules\";\n\nexport default buildModule(\"StorageModule\", (m) => {\n const storage = m.contract(\"Storage\");\n\n return { storage };\n});\n```\n\nDeploy the contract to Polkadot Hub TestNet:\n\n```bash\nnpx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet\n```\n\nYou should see output similar to:\n\n
\n npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet\n WARNING: You are using Node.js 23.11.0 which is not supported by Hardhat.\n Please upgrade to 22.10.0 or a later LTS version (even major version number)\n βœ” Confirm deploy to network polkadotTestNet (420420420)? … yes\n Hardhat Ignition πŸš€\n Deploying [ StorageModule ]\n Batch #1\n Executed StorageModule#Storage\n [ StorageModule ] successfully deployed πŸš€\n Deployed Addresses\n StorageModule#Storage - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3\n
\n\n!!! note\n Save the deployed contract address - you'll need it when building your dApp. In the following sections, we'll reference a pre-deployed contract at `0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3`, but you can use your own deployed contract address instead."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 8, "depth": 3, "title": "Export the Contract ABI", "anchor": "export-the-contract-abi", "start_char": 7216, "end_char": 7603, "estimated_token_count": 89, "token_estimator": "heuristic-v1", "text": "### Export the Contract ABI\n\nAfter deployment, you'll need the contract's Application Binary Interface (ABI) for your dApp. You can find it in the `artifacts/contracts/Storage.sol/Storage.json` file generated by Hardhat. You'll use this in the next section when setting up your dApp.\n\nNow that you have your contract deployed, you're ready to build the dApp that will interact with it!"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 9, "depth": 2, "title": "Set Up the DApp Project", "anchor": "set-up-the-dapp-project", "start_char": 7603, "end_char": 7800, "estimated_token_count": 59, "token_estimator": "heuristic-v1", "text": "## Set Up the DApp Project\n\nNavigate to the root of the project, and create a new Next.js project called `dapp`:\n\n```bash\nnpx create-next-app dapp --ts --eslint --tailwind --app --yes\ncd dapp\n```"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 10, "depth": 2, "title": "Install Dependencies", "anchor": "install-dependencies", "start_char": 7800, "end_char": 7959, "estimated_token_count": 50, "token_estimator": "heuristic-v1", "text": "## Install Dependencies\n\nInstall viem and related packages:\n\n```bash\nnpm install viem@2.38.5\nnpm install --save-dev typescript@5.9.3 @types/node@22.19.24\n```"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 11, "depth": 2, "title": "Connect to Polkadot Hub", "anchor": "connect-to-polkadot-hub", "start_char": 7959, "end_char": 10056, "estimated_token_count": 509, "token_estimator": "heuristic-v1", "text": "## Connect to Polkadot Hub\n\nTo interact with Polkadot Hub, you need to set up a [Public Client](https://viem.sh/docs/clients/public#public-client){target=\\_blank} that connects to the blockchain. In this example, you will interact with the Polkadot Hub TestNet, to experiment safely. Start by creating a new file called `utils/viem.ts` and add the following code:\n\n```typescript title=\"viem.ts\"\nimport { createPublicClient, http, createWalletClient, custom } from 'viem'\nimport 'viem/window';\n\nconst transport = http('http://127.0.0.1:8545') // TODO: change to the paseo asset hub RPC URL when it's available\n\n// Configure the Polkadot Testnet Hub chain\nexport const polkadotTestnet = {\n id: 420420420,\n name: 'Polkadot Testnet',\n network: 'polkadot-testnet',\n nativeCurrency: {\n decimals: 18,\n name: 'PAS',\n symbol: 'PAS',\n },\n rpcUrls: {\n default: {\n http: ['http://127.0.0.1:8545'], // TODO: change to the paseo asset hub RPC URL\n },\n },\n} as const\n\n// Create a public client for reading data\nexport const publicClient = createPublicClient({\n chain: polkadotTestnet,\n transport\n})\n\n// Create a wallet client for signing transactions\nexport const getWalletClient = async () => {\n if (typeof window !== 'undefined' && window.ethereum) {\n const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' });\n return createWalletClient({\n chain: polkadotTestnet,\n transport: custom(window.ethereum),\n account,\n });\n }\n throw new Error('No Ethereum browser provider detected');\n};\n```\n\nThis file initializes a viem client, providing helper functions for obtaining a Public Client and a [Wallet Client](https://viem.sh/docs/clients/wallet#wallet-client){target=\\_blank}. The Public Client enables reading blockchain data, while the Wallet Client allows users to sign and send transactions. Also, note that by importing `viem/window` the global `window.ethereum` will be typed as an `EIP1193Provider`, check the [`window` Polyfill](https://viem.sh/docs/typescript#window-polyfill){target=\\_blank} reference for more information."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 12, "depth": 2, "title": "Set Up the Smart Contract Interface", "anchor": "set-up-the-smart-contract-interface", "start_char": 10056, "end_char": 11967, "estimated_token_count": 422, "token_estimator": "heuristic-v1", "text": "## Set Up the Smart Contract Interface\n\nFor this dApp, you'll use a simple [Storage contract](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/#create-the-contract){target=\\_blank} that's already deployed in the Polkadot Hub TestNet: `0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3`. To interact with it, you need to define the contract interface.\n\nCreate a folder called `abis` at the root of your project, then create a file named `Storage.json` and paste the corresponding ABI of the Storage contract. You can copy and paste the following:\n\n```bash\ncp ./storage-contract/artifacts/contracts/Storage.sol/Storage.json ./dapp/abis/Storage.json\n```\n\nNext, create a file called `utils/contract.ts`:\n\n```typescript title=\"contract.ts\"\nimport { getContract } from 'viem';\nimport { publicClient, getWalletClient } from './viem';\nimport StorageABI from '../abis/Storage.json';\n\nexport const CONTRACT_ADDRESS = '0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3'; // TODO: change when the paseo asset hub RPC URL is available, and the contract is redeployed\nexport const CONTRACT_ABI = StorageABI.abi;\n\n// Create a function to get a contract instance for reading\nexport const getContractInstance = () => {\n return getContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n client: publicClient,\n });\n};\n\n// Create a function to get a contract instance with a signer for writing\nexport const getSignedContract = async () => {\n const walletClient = await getWalletClient();\n return getContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n client: walletClient,\n });\n};\n```\n\nThis file defines the contract address, ABI, and functions to create a viem [contract instance](https://viem.sh/docs/contract/getContract#contract-instances){target=\\_blank} for reading and writing operations. viem's contract utilities enable more efficient, type-safe interaction with smart contracts."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 13, "depth": 2, "title": "Create the Wallet Connection Component", "anchor": "create-the-wallet-connection-component", "start_char": 11967, "end_char": 17994, "estimated_token_count": 1342, "token_estimator": "heuristic-v1", "text": "## Create the Wallet Connection Component\n\nNow, you can create a component to handle wallet connections. Create a new file called `components/WalletConnect.tsx`:\n\n```typescript title=\"WalletConnect.tsx\"\n\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { polkadotTestnet } from \"../utils/viem\";\n\ninterface WalletConnectProps {\n onConnect: (account: string) => void;\n}\n\nconst WalletConnect: React.FC = ({ onConnect }) => {\n const [account, setAccount] = useState(null);\n const [chainId, setChainId] = useState(null);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n // Check if user already has an authorized wallet connection\n const checkConnection = async () => {\n if (typeof window !== 'undefined' && window.ethereum) {\n try {\n // eth_accounts doesn't trigger the wallet popup\n const accounts = await window.ethereum.request({\n method: 'eth_accounts',\n }) as string[];\n \n if (accounts.length > 0) {\n setAccount(accounts[0]);\n const chainIdHex = await window.ethereum.request({\n method: 'eth_chainId',\n }) as string;\n setChainId(parseInt(chainIdHex, 16));\n onConnect(accounts[0]);\n }\n } catch (err) {\n console.error('Error checking connection:', err);\n setError('Failed to check wallet connection');\n }\n }\n };\n\n checkConnection();\n\n if (typeof window !== 'undefined' && window.ethereum) {\n // Setup wallet event listeners\n window.ethereum.on('accountsChanged', (accounts: string[]) => {\n setAccount(accounts[0] || null);\n if (accounts[0]) onConnect(accounts[0]);\n });\n\n window.ethereum.on('chainChanged', (chainIdHex: string) => {\n setChainId(parseInt(chainIdHex, 16));\n });\n }\n\n return () => {\n // Cleanup event listeners\n if (typeof window !== 'undefined' && window.ethereum) {\n window.ethereum.removeListener('accountsChanged', () => {});\n window.ethereum.removeListener('chainChanged', () => {});\n }\n };\n }, [onConnect]);\n\n const connectWallet = async () => {\n if (typeof window === 'undefined' || !window.ethereum) {\n setError(\n 'MetaMask not detected! Please install MetaMask to use this dApp.'\n );\n return;\n }\n\n try {\n // eth_requestAccounts triggers the wallet popup\n const accounts = await window.ethereum.request({\n method: 'eth_requestAccounts',\n }) as string[];\n \n setAccount(accounts[0]);\n\n const chainIdHex = await window.ethereum.request({\n method: 'eth_chainId',\n }) as string;\n \n const currentChainId = parseInt(chainIdHex, 16);\n setChainId(currentChainId);\n\n // Prompt user to switch networks if needed\n if (currentChainId !== polkadotTestnet.id) {\n await switchNetwork();\n }\n\n onConnect(accounts[0]);\n } catch (err) {\n console.error('Error connecting to wallet:', err);\n setError('Failed to connect wallet');\n }\n };\n\n const switchNetwork = async () => {\n console.log('Switch network')\n try {\n await window.ethereum.request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: `0x${polkadotTestnet.id.toString(16)}` }],\n });\n } catch (switchError: any) {\n // Error 4902 means the chain hasn't been added to MetaMask\n if (switchError.code === 4902) {\n try {\n await window.ethereum.request({\n method: 'wallet_addEthereumChain',\n params: [\n {\n chainId: `0x${polkadotTestnet.id.toString(16)}`,\n chainName: polkadotTestnet.name,\n rpcUrls: [polkadotTestnet.rpcUrls.default.http[0]],\n nativeCurrency: {\n name: polkadotTestnet.nativeCurrency.name,\n symbol: polkadotTestnet.nativeCurrency.symbol,\n decimals: polkadotTestnet.nativeCurrency.decimals,\n },\n },\n ],\n });\n } catch (addError) {\n setError('Failed to add network to wallet');\n }\n } else {\n setError('Failed to switch network');\n }\n }\n };\n\n // UI-only disconnection - MetaMask doesn't support programmatic disconnection\n const disconnectWallet = () => {\n setAccount(null);\n };\n\n return (\n
\n {error &&

{error}

}\n\n {!account ? (\n \n Connect Wallet\n \n ) : (\n
\n \n {`${account.substring(0, 6)}...${account.substring(38)}`}\n \n \n Disconnect\n \n {chainId !== polkadotTestnet.id && (\n \n Switch to Polkadot Testnet\n \n )}\n
\n )}\n
\n );\n};\n\nexport default WalletConnect;\n```\n\nThis component handles connecting to the wallet, switching networks if necessary, and keeping track of the connected account. It provides a button for users to connect their wallet and displays the connected account address once connected."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 14, "depth": 2, "title": "Create the Read Contract Component", "anchor": "create-the-read-contract-component", "start_char": 17994, "end_char": 20523, "estimated_token_count": 614, "token_estimator": "heuristic-v1", "text": "## Create the Read Contract Component\n\nNext, create a component to read data from the contract. Create a file called `components/ReadContract.tsx`:\n\n```typescript title=\"ReadContract.tsx\"\n'use client';\n\nimport React, { useState, useEffect } from 'react';\nimport { publicClient } from '../utils/viem';\nimport { CONTRACT_ADDRESS, CONTRACT_ABI } from '../utils/contract';\n\nconst ReadContract: React.FC = () => {\n const [storedNumber, setStoredNumber] = useState(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n // Function to read data from the blockchain\n const fetchData = async () => {\n try {\n setLoading(true);\n // Call the smart contract's storedNumber function\n const number = await publicClient.readContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n functionName: 'storedNumber',\n args: [],\n }) as bigint;\n\n setStoredNumber(number.toString());\n setError(null);\n } catch (err) {\n console.error('Error fetching stored number:', err);\n setError('Failed to fetch data from the contract');\n } finally {\n setLoading(false);\n }\n };\n\n fetchData();\n\n // Poll for updates every 10 seconds to keep UI in sync with blockchain\n const interval = setInterval(fetchData, 10000);\n\n // Clean up interval on component unmount\n return () => clearInterval(interval);\n }, []);\n\n return (\n
\n

Contract Data

\n {loading ? (\n
\n
\n
\n ) : error ? (\n

{error}

\n ) : (\n
\n

\n Stored Number: {storedNumber}\n

\n
\n )}\n
\n );\n};\n\nexport default ReadContract;\n```\n\nThis component reads the `storedNumber` value from the contract and displays it to the user. It also sets up a polling interval to refresh the data periodically, ensuring that the UI stays in sync with the blockchain state."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 15, "depth": 2, "title": "Create the Write Contract Component", "anchor": "create-the-write-contract-component", "start_char": 20523, "end_char": 28626, "estimated_token_count": 1822, "token_estimator": "heuristic-v1", "text": "## Create the Write Contract Component\n\nFinally, create a component that allows users to update the stored number. Create a file called `components/WriteContract.tsx`:\n\n```typescript title=\"WriteContract.tsx\"\n\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { publicClient, getWalletClient } from '../utils/viem';\nimport { CONTRACT_ADDRESS, CONTRACT_ABI } from '../utils/contract';\n\ninterface WriteContractProps {\n account: string | null;\n}\n\nconst WriteContract: React.FC = ({ account }) => {\n const [newNumber, setNewNumber] = useState(\"\");\n const [status, setStatus] = useState<{\n type: string | null;\n message: string;\n }>({\n type: null,\n message: \"\",\n });\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isCorrectNetwork, setIsCorrectNetwork] = useState(true);\n\n // Check if the account is on the correct network\n useEffect(() => {\n const checkNetwork = async () => {\n if (!account) return;\n\n try {\n // Get the chainId from the public client\n const chainId = await publicClient.getChainId();\n\n // Get the user's current chainId from their wallet\n const walletClient = await getWalletClient();\n if (!walletClient) return;\n\n const walletChainId = await walletClient.getChainId();\n\n // Check if they match\n setIsCorrectNetwork(chainId === walletChainId);\n } catch (err) {\n console.error(\"Error checking network:\", err);\n setIsCorrectNetwork(false);\n }\n };\n\n checkNetwork();\n }, [account]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n\n // Validation checks\n if (!account) {\n setStatus({ type: \"error\", message: \"Please connect your wallet first\" });\n return;\n }\n\n if (!isCorrectNetwork) {\n setStatus({\n type: \"error\",\n message: \"Please switch to the correct network in your wallet\",\n });\n return;\n }\n\n if (!newNumber || isNaN(Number(newNumber))) {\n setStatus({ type: \"error\", message: \"Please enter a valid number\" });\n return;\n }\n\n try {\n setIsSubmitting(true);\n setStatus({ type: \"info\", message: \"Initiating transaction...\" });\n\n // Get wallet client for transaction signing\n const walletClient = await getWalletClient();\n\n if (!walletClient) {\n setStatus({ type: \"error\", message: \"Wallet client not available\" });\n return;\n }\n\n // Check if account matches\n if (\n walletClient.account?.address.toLowerCase() !== account.toLowerCase()\n ) {\n setStatus({\n type: \"error\",\n message:\n \"Connected wallet account doesn't match the selected account\",\n });\n return;\n }\n\n // Prepare transaction and wait for user confirmation in wallet\n setStatus({\n type: \"info\",\n message: \"Please confirm the transaction in your wallet...\",\n });\n\n // Simulate the contract call first\n console.log('newNumber', newNumber);\n const { request } = await publicClient.simulateContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n functionName: \"setNumber\",\n args: [BigInt(newNumber)],\n account: walletClient.account,\n });\n\n // Send the transaction with wallet client\n const hash = await walletClient.writeContract(request);\n\n // Wait for transaction to be mined\n setStatus({\n type: \"info\",\n message: \"Transaction submitted. Waiting for confirmation...\",\n });\n\n const receipt = await publicClient.waitForTransactionReceipt({\n hash,\n });\n\n setStatus({\n type: \"success\",\n message: `Transaction confirmed! Transaction hash: ${receipt.transactionHash}`,\n });\n\n setNewNumber(\"\");\n } catch (err: any) {\n console.error(\"Error updating number:\", err);\n\n // Handle specific errors\n if (err.code === 4001) {\n // User rejected transaction\n setStatus({ type: \"error\", message: \"Transaction rejected by user.\" });\n } else if (err.message?.includes(\"Account not found\")) {\n // Account not found on the network\n setStatus({\n type: \"error\",\n message:\n \"Account not found on current network. Please check your wallet is connected to the correct network.\",\n });\n } else if (err.message?.includes(\"JSON is not a valid request object\")) {\n // JSON error - specific to your current issue\n setStatus({\n type: \"error\",\n message:\n \"Invalid request format. Please try again or contact support.\",\n });\n } else {\n // Other errors\n setStatus({\n type: \"error\",\n message: `Error: ${err.message || \"Failed to send transaction\"}`,\n });\n }\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n
\n

Update Stored Number

\n\n {!isCorrectNetwork && account && (\n
\n ⚠️ You are not connected to the correct network. Please switch\n networks in your wallet.\n
\n )}\n\n {status.message && (\n \n {status.message}\n
\n )}\n\n
\n setNewNumber(e.target.value)}\n disabled={isSubmitting || !account}\n className=\"w-full p-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-pink-400\"\n />\n \n {isSubmitting ? \"Updating...\" : \"Update\"}\n \n \n\n {!account && (\n

\n Connect your wallet to update the stored number.\n

\n )}\n
\n );\n};\n\nexport default WriteContract;\n```\n\nThis component allows users to input a new number and send a transaction to update the value stored in the contract. It provides appropriate feedback during each step of the transaction process and handles error scenarios.\n\nUpdate the `app/page.tsx` file to integrate all components:\n\n```typescript title=\"page.tsx\"\n\"use client\";\n\nimport { useState } from \"react\";\nimport WalletConnect from \"./components/WalletConnect\";\nimport ReadContract from \"./components/ReadContract\";\nimport WriteContract from \"./components/WriteContract\";\n\nexport default function Home() {\n const [account, setAccount] = useState(null);\n\n const handleConnect = (connectedAccount: string) => {\n setAccount(connectedAccount);\n };\n\n return (\n
\n

\n Polkadot Hub - Zero To Hero DApp\n

\n \n \n \n
\n );\n}\n```\n\nRun the dApp:\n\n```bash\nnpm run dev\n```\n\nNavigate to `http://localhost:3000` in your browser, and you should see your dApp with the wallet connection button, the stored number displayed, and the form to update the number. You should see something like this:"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 16, "depth": 2, "title": "How It Works", "anchor": "how-it-works", "start_char": 28626, "end_char": 28719, "estimated_token_count": 18, "token_estimator": "heuristic-v1", "text": "## How It Works\n\nThis dApp uses components to interact with the blockchain in several ways."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 17, "depth": 3, "title": "Wallet Connection", "anchor": "wallet-connection", "start_char": 28719, "end_char": 29025, "estimated_token_count": 60, "token_estimator": "heuristic-v1", "text": "### Wallet Connection \n\nThe `WalletConnect` component uses the browser's Ethereum provider (MetaMask) to connect to the user's wallet and handles network switching to ensure the user is connected to the Polkadot Hub TestNet. Once connected, it provides the user's account address to the parent component."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 18, "depth": 3, "title": "Data Reads", "anchor": "data-reads", "start_char": 29025, "end_char": 29326, "estimated_token_count": 57, "token_estimator": "heuristic-v1", "text": "### Data Reads\n\nThe `ReadContract` component uses viem's `readContract` function to call the `storedNumber` view function and periodically poll for updates to keep the UI in sync with the blockchain state. The component also displays a loading indicator while fetching data and handles error states."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 19, "depth": 3, "title": "Data Writes", "anchor": "data-writes", "start_char": 29326, "end_char": 29728, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "### Data Writes\n\nThe `WriteContract` component uses viem's `writeContract` function to send a transaction to the `setNumber` function and ensures the wallet is connected before allowing a transaction. The component shows detailed feedback during transaction submission and confirmation. After a successful transaction, the value displayed in the `ReadContract` component will update on the next poll."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 20, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 29728, "end_char": 30625, "estimated_token_count": 178, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nCongratulations! You've successfully built a fully functional dApp that interacts with a smart contract on Polkadot Hub using viem and Next.js. Your application can now:\n\n- Create a smart contract with Hardhat and deploy it to Polkadot Hub TestNet.\n- Connect to a user's wallet and handle network switching.\n- Read data from a smart contract and keep it updated.\n- Write data to the blockchain through transactions.\n\nThese fundamental skills provide the foundation for building more complex dApps on Polkadot Hub. With this knowledge, you can extend your application to interact with more sophisticated smart contracts and create advanced user interfaces.\n\nTo get started right away with a working example, you can clone the repository and navigate to the implementation:\n\n```bash\ngit clone https://github.com/polkadot-developers/revm-hardhat-examples.git\ncd zero-to-hero-dapp\n```"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 21, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 30625, "end_char": 31211, "estimated_token_count": 147, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Port Ethereum Projects to Polkadot Hub__\n\n ---\n\n Learn how to port an Ethereum project to Polkadot Hub using Hardhat and Viem.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/eth-dapps/uniswap-v2/)\n\n- Guide __Dive Deeper into Polkadot Precompiles__\n\n ---\n\n Learn how to use the Polkadot precompiles to interact with the blockchain.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/precompiles/)\n
"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 5, "depth": 3, "title": "Configure Hardhat for Polkadot Hub", "anchor": "configure-hardhat-for-polkadot-hub", "start_char": 3633, "end_char": 5453, "estimated_token_count": 415, "token_estimator": "heuristic-v1", "text": "### Configure Hardhat for Polkadot Hub\n\nUpdate your `hardhat.config.ts` file to include the Polkadot Hub TestNet configuration:\n\n```typescript title=\"hardhat.config.ts\" hl_lines=\"39-44\"\nimport type { HardhatUserConfig } from \"hardhat/config\";\n\nimport hardhatToolboxViemPlugin from \"@nomicfoundation/hardhat-toolbox-viem\";\nimport { configVariable } from \"hardhat/config\";\n\nconst config: HardhatUserConfig = {\n plugins: [hardhatToolboxViemPlugin],\n solidity: {\n profiles: {\n default: {\n version: \"0.8.28\",\n },\n production: {\n version: \"0.8.28\",\n settings: {\n optimizer: {\n enabled: true,\n runs: 200,\n },\n },\n },\n },\n },\n networks: {\n hardhatMainnet: {\n type: \"edr-simulated\",\n chainType: \"l1\",\n },\n hardhatOp: {\n type: \"edr-simulated\",\n chainType: \"op\",\n },\n sepolia: {\n type: \"http\",\n chainType: \"l1\",\n url: configVariable(\"SEPOLIA_RPC_URL\"),\n accounts: [configVariable(\"SEPOLIA_PRIVATE_KEY\")],\n },\n polkadotTestNet: {\n type: \"http\",\n chainType: \"l1\",\n url: 'https://services.polkadothub-rpc.com/testnet',\n accounts: [process.env.PRIVATE_KEY || ''],\n },\n },\n};\n\nexport default config;\n```\n\nCreate a `.env` file in the root of your Hardhat project:\n\n```text title=\".env\"\nPRIVATE_KEY=INSERT_PRIVATE_KEY_HERE\n```\n\nReplace `INSERT_PRIVATE_KEY_HERE` with your actual private key. You can get this by exporting the private key from your wallet (e.g., MetaMask).\n\n!!! warning\n Never commit your private key to version control. Use environment variables or a `.env` file (and add it to `.gitignore`) to manage sensitive information. Keep your private key safe, and never share it with anyone. If it is compromised, your funds can be stolen."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 6, "depth": 3, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 5453, "end_char": 5602, "estimated_token_count": 29, "token_estimator": "heuristic-v1", "text": "### Compile the Contract\n\nCompile your Storage contract:\n\n```bash\nnpx hardhat compile\n```\n\nYou should see output indicating successful compilation."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 7, "depth": 3, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 5602, "end_char": 7239, "estimated_token_count": 416, "token_estimator": "heuristic-v1", "text": "### Deploy the Contract\n\nCreate a deployment script in the `ignition/modules` directory called `Storage.ts`:\n\n```typescript title=\"Storage.ts\"\nimport { buildModule } from \"@nomicfoundation/hardhat-ignition/modules\";\n\nexport default buildModule(\"StorageModule\", (m) => {\n const storage = m.contract(\"Storage\");\n\n return { storage };\n});\n```\n\nDeploy the contract to Polkadot Hub TestNet:\n\n```bash\nnpx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet\n```\n\nYou should see output similar to:\n\n
\n npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet\n WARNING: You are using Node.js 23.11.0 which is not supported by Hardhat.\n Please upgrade to 22.10.0 or a later LTS version (even major version number)\n βœ” Confirm deploy to network polkadotTestNet (420420417)? … yes\n Hardhat Ignition πŸš€\n Deploying [ StorageModule ]\n Batch #1\n Executed StorageModule#Storage\n [ StorageModule ] successfully deployed πŸš€\n Deployed Addresses\n StorageModule#Storage - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3\n
\n\n!!! note\n Save the deployed contract address - you'll need it when building your dApp. In the following sections, we'll reference a pre-deployed contract at `0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3`, but you can use your own deployed contract address instead."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 8, "depth": 3, "title": "Export the Contract ABI", "anchor": "export-the-contract-abi", "start_char": 7239, "end_char": 7626, "estimated_token_count": 89, "token_estimator": "heuristic-v1", "text": "### Export the Contract ABI\n\nAfter deployment, you'll need the contract's Application Binary Interface (ABI) for your dApp. You can find it in the `artifacts/contracts/Storage.sol/Storage.json` file generated by Hardhat. You'll use this in the next section when setting up your dApp.\n\nNow that you have your contract deployed, you're ready to build the dApp that will interact with it!"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 9, "depth": 2, "title": "Set Up the DApp Project", "anchor": "set-up-the-dapp-project", "start_char": 7626, "end_char": 7823, "estimated_token_count": 59, "token_estimator": "heuristic-v1", "text": "## Set Up the DApp Project\n\nNavigate to the root of the project, and create a new Next.js project called `dapp`:\n\n```bash\nnpx create-next-app dapp --ts --eslint --tailwind --app --yes\ncd dapp\n```"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 10, "depth": 2, "title": "Install Dependencies", "anchor": "install-dependencies", "start_char": 7823, "end_char": 7982, "estimated_token_count": 50, "token_estimator": "heuristic-v1", "text": "## Install Dependencies\n\nInstall viem and related packages:\n\n```bash\nnpm install viem@2.38.5\nnpm install --save-dev typescript@5.9.3 @types/node@22.19.24\n```"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 11, "depth": 2, "title": "Connect to Polkadot Hub", "anchor": "connect-to-polkadot-hub", "start_char": 7982, "end_char": 10011, "estimated_token_count": 480, "token_estimator": "heuristic-v1", "text": "## Connect to Polkadot Hub\n\nTo interact with Polkadot Hub, you need to set up a [Public Client](https://viem.sh/docs/clients/public#public-client){target=\\_blank} that connects to the blockchain. In this example, you will interact with the Polkadot Hub TestNet, to experiment safely. Start by creating a new file called `utils/viem.ts` and add the following code:\n\n```typescript title=\"viem.ts\"\nimport { createPublicClient, http, createWalletClient, custom } from 'viem'\nimport 'viem/window';\n\nconst transport = http('https://services.polkadothub-rpc.com/testnet')\n\n// Configure the Polkadot Testnet Hub chain\nexport const polkadotTestnet = {\n id: 420420420,\n name: 'Polkadot Testnet',\n network: 'polkadot-testnet',\n nativeCurrency: {\n decimals: 18,\n name: 'PAS',\n symbol: 'PAS',\n },\n rpcUrls: {\n default: {\n http: ['https://services.polkadothub-rpc.com/testnet'],\n },\n },\n} as const\n\n// Create a public client for reading data\nexport const publicClient = createPublicClient({\n chain: polkadotTestnet,\n transport\n})\n\n// Create a wallet client for signing transactions\nexport const getWalletClient = async () => {\n if (typeof window !== 'undefined' && window.ethereum) {\n const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' });\n return createWalletClient({\n chain: polkadotTestnet,\n transport: custom(window.ethereum),\n account,\n });\n }\n throw new Error('No Ethereum browser provider detected');\n};\n```\n\nThis file initializes a viem client, providing helper functions for obtaining a Public Client and a [Wallet Client](https://viem.sh/docs/clients/wallet#wallet-client){target=\\_blank}. The Public Client enables reading blockchain data, while the Wallet Client allows users to sign and send transactions. Also, note that by importing `viem/window` the global `window.ethereum` will be typed as an `EIP1193Provider`, check the [`window` Polyfill](https://viem.sh/docs/typescript#window-polyfill){target=\\_blank} reference for more information."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 12, "depth": 2, "title": "Set Up the Smart Contract Interface", "anchor": "set-up-the-smart-contract-interface", "start_char": 10011, "end_char": 11922, "estimated_token_count": 422, "token_estimator": "heuristic-v1", "text": "## Set Up the Smart Contract Interface\n\nFor this dApp, you'll use a simple [Storage contract](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/#create-the-contract){target=\\_blank} that's already deployed in the Polkadot Hub TestNet: `0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3`. To interact with it, you need to define the contract interface.\n\nCreate a folder called `abis` at the root of your project, then create a file named `Storage.json` and paste the corresponding ABI of the Storage contract. You can copy and paste the following:\n\n```bash\ncp ./storage-contract/artifacts/contracts/Storage.sol/Storage.json ./dapp/abis/Storage.json\n```\n\nNext, create a file called `utils/contract.ts`:\n\n```typescript title=\"contract.ts\"\nimport { getContract } from 'viem';\nimport { publicClient, getWalletClient } from './viem';\nimport StorageABI from '../abis/Storage.json';\n\nexport const CONTRACT_ADDRESS = '0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3'; // TODO: change when the paseo asset hub RPC URL is available, and the contract is redeployed\nexport const CONTRACT_ABI = StorageABI.abi;\n\n// Create a function to get a contract instance for reading\nexport const getContractInstance = () => {\n return getContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n client: publicClient,\n });\n};\n\n// Create a function to get a contract instance with a signer for writing\nexport const getSignedContract = async () => {\n const walletClient = await getWalletClient();\n return getContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n client: walletClient,\n });\n};\n```\n\nThis file defines the contract address, ABI, and functions to create a viem [contract instance](https://viem.sh/docs/contract/getContract#contract-instances){target=\\_blank} for reading and writing operations. viem's contract utilities enable more efficient, type-safe interaction with smart contracts."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 13, "depth": 2, "title": "Create the Wallet Connection Component", "anchor": "create-the-wallet-connection-component", "start_char": 11922, "end_char": 17949, "estimated_token_count": 1342, "token_estimator": "heuristic-v1", "text": "## Create the Wallet Connection Component\n\nNow, you can create a component to handle wallet connections. Create a new file called `components/WalletConnect.tsx`:\n\n```typescript title=\"WalletConnect.tsx\"\n\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { polkadotTestnet } from \"../utils/viem\";\n\ninterface WalletConnectProps {\n onConnect: (account: string) => void;\n}\n\nconst WalletConnect: React.FC = ({ onConnect }) => {\n const [account, setAccount] = useState(null);\n const [chainId, setChainId] = useState(null);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n // Check if user already has an authorized wallet connection\n const checkConnection = async () => {\n if (typeof window !== 'undefined' && window.ethereum) {\n try {\n // eth_accounts doesn't trigger the wallet popup\n const accounts = await window.ethereum.request({\n method: 'eth_accounts',\n }) as string[];\n \n if (accounts.length > 0) {\n setAccount(accounts[0]);\n const chainIdHex = await window.ethereum.request({\n method: 'eth_chainId',\n }) as string;\n setChainId(parseInt(chainIdHex, 16));\n onConnect(accounts[0]);\n }\n } catch (err) {\n console.error('Error checking connection:', err);\n setError('Failed to check wallet connection');\n }\n }\n };\n\n checkConnection();\n\n if (typeof window !== 'undefined' && window.ethereum) {\n // Setup wallet event listeners\n window.ethereum.on('accountsChanged', (accounts: string[]) => {\n setAccount(accounts[0] || null);\n if (accounts[0]) onConnect(accounts[0]);\n });\n\n window.ethereum.on('chainChanged', (chainIdHex: string) => {\n setChainId(parseInt(chainIdHex, 16));\n });\n }\n\n return () => {\n // Cleanup event listeners\n if (typeof window !== 'undefined' && window.ethereum) {\n window.ethereum.removeListener('accountsChanged', () => {});\n window.ethereum.removeListener('chainChanged', () => {});\n }\n };\n }, [onConnect]);\n\n const connectWallet = async () => {\n if (typeof window === 'undefined' || !window.ethereum) {\n setError(\n 'MetaMask not detected! Please install MetaMask to use this dApp.'\n );\n return;\n }\n\n try {\n // eth_requestAccounts triggers the wallet popup\n const accounts = await window.ethereum.request({\n method: 'eth_requestAccounts',\n }) as string[];\n \n setAccount(accounts[0]);\n\n const chainIdHex = await window.ethereum.request({\n method: 'eth_chainId',\n }) as string;\n \n const currentChainId = parseInt(chainIdHex, 16);\n setChainId(currentChainId);\n\n // Prompt user to switch networks if needed\n if (currentChainId !== polkadotTestnet.id) {\n await switchNetwork();\n }\n\n onConnect(accounts[0]);\n } catch (err) {\n console.error('Error connecting to wallet:', err);\n setError('Failed to connect wallet');\n }\n };\n\n const switchNetwork = async () => {\n console.log('Switch network')\n try {\n await window.ethereum.request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: `0x${polkadotTestnet.id.toString(16)}` }],\n });\n } catch (switchError: any) {\n // Error 4902 means the chain hasn't been added to MetaMask\n if (switchError.code === 4902) {\n try {\n await window.ethereum.request({\n method: 'wallet_addEthereumChain',\n params: [\n {\n chainId: `0x${polkadotTestnet.id.toString(16)}`,\n chainName: polkadotTestnet.name,\n rpcUrls: [polkadotTestnet.rpcUrls.default.http[0]],\n nativeCurrency: {\n name: polkadotTestnet.nativeCurrency.name,\n symbol: polkadotTestnet.nativeCurrency.symbol,\n decimals: polkadotTestnet.nativeCurrency.decimals,\n },\n },\n ],\n });\n } catch (addError) {\n setError('Failed to add network to wallet');\n }\n } else {\n setError('Failed to switch network');\n }\n }\n };\n\n // UI-only disconnection - MetaMask doesn't support programmatic disconnection\n const disconnectWallet = () => {\n setAccount(null);\n };\n\n return (\n
\n {error &&

{error}

}\n\n {!account ? (\n \n Connect Wallet\n \n ) : (\n
\n \n {`${account.substring(0, 6)}...${account.substring(38)}`}\n \n \n Disconnect\n \n {chainId !== polkadotTestnet.id && (\n \n Switch to Polkadot Testnet\n \n )}\n
\n )}\n
\n );\n};\n\nexport default WalletConnect;\n```\n\nThis component handles connecting to the wallet, switching networks if necessary, and keeping track of the connected account. It provides a button for users to connect their wallet and displays the connected account address once connected."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 14, "depth": 2, "title": "Create the Read Contract Component", "anchor": "create-the-read-contract-component", "start_char": 17949, "end_char": 20478, "estimated_token_count": 614, "token_estimator": "heuristic-v1", "text": "## Create the Read Contract Component\n\nNext, create a component to read data from the contract. Create a file called `components/ReadContract.tsx`:\n\n```typescript title=\"ReadContract.tsx\"\n'use client';\n\nimport React, { useState, useEffect } from 'react';\nimport { publicClient } from '../utils/viem';\nimport { CONTRACT_ADDRESS, CONTRACT_ABI } from '../utils/contract';\n\nconst ReadContract: React.FC = () => {\n const [storedNumber, setStoredNumber] = useState(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n // Function to read data from the blockchain\n const fetchData = async () => {\n try {\n setLoading(true);\n // Call the smart contract's storedNumber function\n const number = await publicClient.readContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n functionName: 'storedNumber',\n args: [],\n }) as bigint;\n\n setStoredNumber(number.toString());\n setError(null);\n } catch (err) {\n console.error('Error fetching stored number:', err);\n setError('Failed to fetch data from the contract');\n } finally {\n setLoading(false);\n }\n };\n\n fetchData();\n\n // Poll for updates every 10 seconds to keep UI in sync with blockchain\n const interval = setInterval(fetchData, 10000);\n\n // Clean up interval on component unmount\n return () => clearInterval(interval);\n }, []);\n\n return (\n
\n

Contract Data

\n {loading ? (\n
\n
\n
\n ) : error ? (\n

{error}

\n ) : (\n
\n

\n Stored Number: {storedNumber}\n

\n
\n )}\n
\n );\n};\n\nexport default ReadContract;\n```\n\nThis component reads the `storedNumber` value from the contract and displays it to the user. It also sets up a polling interval to refresh the data periodically, ensuring that the UI stays in sync with the blockchain state."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 15, "depth": 2, "title": "Create the Write Contract Component", "anchor": "create-the-write-contract-component", "start_char": 20478, "end_char": 28581, "estimated_token_count": 1822, "token_estimator": "heuristic-v1", "text": "## Create the Write Contract Component\n\nFinally, create a component that allows users to update the stored number. Create a file called `components/WriteContract.tsx`:\n\n```typescript title=\"WriteContract.tsx\"\n\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { publicClient, getWalletClient } from '../utils/viem';\nimport { CONTRACT_ADDRESS, CONTRACT_ABI } from '../utils/contract';\n\ninterface WriteContractProps {\n account: string | null;\n}\n\nconst WriteContract: React.FC = ({ account }) => {\n const [newNumber, setNewNumber] = useState(\"\");\n const [status, setStatus] = useState<{\n type: string | null;\n message: string;\n }>({\n type: null,\n message: \"\",\n });\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isCorrectNetwork, setIsCorrectNetwork] = useState(true);\n\n // Check if the account is on the correct network\n useEffect(() => {\n const checkNetwork = async () => {\n if (!account) return;\n\n try {\n // Get the chainId from the public client\n const chainId = await publicClient.getChainId();\n\n // Get the user's current chainId from their wallet\n const walletClient = await getWalletClient();\n if (!walletClient) return;\n\n const walletChainId = await walletClient.getChainId();\n\n // Check if they match\n setIsCorrectNetwork(chainId === walletChainId);\n } catch (err) {\n console.error(\"Error checking network:\", err);\n setIsCorrectNetwork(false);\n }\n };\n\n checkNetwork();\n }, [account]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n\n // Validation checks\n if (!account) {\n setStatus({ type: \"error\", message: \"Please connect your wallet first\" });\n return;\n }\n\n if (!isCorrectNetwork) {\n setStatus({\n type: \"error\",\n message: \"Please switch to the correct network in your wallet\",\n });\n return;\n }\n\n if (!newNumber || isNaN(Number(newNumber))) {\n setStatus({ type: \"error\", message: \"Please enter a valid number\" });\n return;\n }\n\n try {\n setIsSubmitting(true);\n setStatus({ type: \"info\", message: \"Initiating transaction...\" });\n\n // Get wallet client for transaction signing\n const walletClient = await getWalletClient();\n\n if (!walletClient) {\n setStatus({ type: \"error\", message: \"Wallet client not available\" });\n return;\n }\n\n // Check if account matches\n if (\n walletClient.account?.address.toLowerCase() !== account.toLowerCase()\n ) {\n setStatus({\n type: \"error\",\n message:\n \"Connected wallet account doesn't match the selected account\",\n });\n return;\n }\n\n // Prepare transaction and wait for user confirmation in wallet\n setStatus({\n type: \"info\",\n message: \"Please confirm the transaction in your wallet...\",\n });\n\n // Simulate the contract call first\n console.log('newNumber', newNumber);\n const { request } = await publicClient.simulateContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n functionName: \"setNumber\",\n args: [BigInt(newNumber)],\n account: walletClient.account,\n });\n\n // Send the transaction with wallet client\n const hash = await walletClient.writeContract(request);\n\n // Wait for transaction to be mined\n setStatus({\n type: \"info\",\n message: \"Transaction submitted. Waiting for confirmation...\",\n });\n\n const receipt = await publicClient.waitForTransactionReceipt({\n hash,\n });\n\n setStatus({\n type: \"success\",\n message: `Transaction confirmed! Transaction hash: ${receipt.transactionHash}`,\n });\n\n setNewNumber(\"\");\n } catch (err: any) {\n console.error(\"Error updating number:\", err);\n\n // Handle specific errors\n if (err.code === 4001) {\n // User rejected transaction\n setStatus({ type: \"error\", message: \"Transaction rejected by user.\" });\n } else if (err.message?.includes(\"Account not found\")) {\n // Account not found on the network\n setStatus({\n type: \"error\",\n message:\n \"Account not found on current network. Please check your wallet is connected to the correct network.\",\n });\n } else if (err.message?.includes(\"JSON is not a valid request object\")) {\n // JSON error - specific to your current issue\n setStatus({\n type: \"error\",\n message:\n \"Invalid request format. Please try again or contact support.\",\n });\n } else {\n // Other errors\n setStatus({\n type: \"error\",\n message: `Error: ${err.message || \"Failed to send transaction\"}`,\n });\n }\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n
\n

Update Stored Number

\n\n {!isCorrectNetwork && account && (\n
\n ⚠️ You are not connected to the correct network. Please switch\n networks in your wallet.\n
\n )}\n\n {status.message && (\n \n {status.message}\n
\n )}\n\n
\n setNewNumber(e.target.value)}\n disabled={isSubmitting || !account}\n className=\"w-full p-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-pink-400\"\n />\n \n {isSubmitting ? \"Updating...\" : \"Update\"}\n \n \n\n {!account && (\n

\n Connect your wallet to update the stored number.\n

\n )}\n
\n );\n};\n\nexport default WriteContract;\n```\n\nThis component allows users to input a new number and send a transaction to update the value stored in the contract. It provides appropriate feedback during each step of the transaction process and handles error scenarios.\n\nUpdate the `app/page.tsx` file to integrate all components:\n\n```typescript title=\"page.tsx\"\n\"use client\";\n\nimport { useState } from \"react\";\nimport WalletConnect from \"./components/WalletConnect\";\nimport ReadContract from \"./components/ReadContract\";\nimport WriteContract from \"./components/WriteContract\";\n\nexport default function Home() {\n const [account, setAccount] = useState(null);\n\n const handleConnect = (connectedAccount: string) => {\n setAccount(connectedAccount);\n };\n\n return (\n
\n

\n Polkadot Hub - Zero To Hero DApp\n

\n \n \n \n
\n );\n}\n```\n\nRun the dApp:\n\n```bash\nnpm run dev\n```\n\nNavigate to `http://localhost:3000` in your browser, and you should see your dApp with the wallet connection button, the stored number displayed, and the form to update the number. You should see something like this:"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 16, "depth": 2, "title": "How It Works", "anchor": "how-it-works", "start_char": 28581, "end_char": 28674, "estimated_token_count": 18, "token_estimator": "heuristic-v1", "text": "## How It Works\n\nThis dApp uses components to interact with the blockchain in several ways."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 17, "depth": 3, "title": "Wallet Connection", "anchor": "wallet-connection", "start_char": 28674, "end_char": 28980, "estimated_token_count": 60, "token_estimator": "heuristic-v1", "text": "### Wallet Connection \n\nThe `WalletConnect` component uses the browser's Ethereum provider (MetaMask) to connect to the user's wallet and handles network switching to ensure the user is connected to the Polkadot Hub TestNet. Once connected, it provides the user's account address to the parent component."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 18, "depth": 3, "title": "Data Reads", "anchor": "data-reads", "start_char": 28980, "end_char": 29281, "estimated_token_count": 57, "token_estimator": "heuristic-v1", "text": "### Data Reads\n\nThe `ReadContract` component uses viem's `readContract` function to call the `storedNumber` view function and periodically poll for updates to keep the UI in sync with the blockchain state. The component also displays a loading indicator while fetching data and handles error states."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 19, "depth": 3, "title": "Data Writes", "anchor": "data-writes", "start_char": 29281, "end_char": 29683, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "### Data Writes\n\nThe `WriteContract` component uses viem's `writeContract` function to send a transaction to the `setNumber` function and ensures the wallet is connected before allowing a transaction. The component shows detailed feedback during transaction submission and confirmation. After a successful transaction, the value displayed in the `ReadContract` component will update on the next poll."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 20, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 29683, "end_char": 30580, "estimated_token_count": 178, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nCongratulations! You've successfully built a fully functional dApp that interacts with a smart contract on Polkadot Hub using viem and Next.js. Your application can now:\n\n- Create a smart contract with Hardhat and deploy it to Polkadot Hub TestNet.\n- Connect to a user's wallet and handle network switching.\n- Read data from a smart contract and keep it updated.\n- Write data to the blockchain through transactions.\n\nThese fundamental skills provide the foundation for building more complex dApps on Polkadot Hub. With this knowledge, you can extend your application to interact with more sophisticated smart contracts and create advanced user interfaces.\n\nTo get started right away with a working example, you can clone the repository and navigate to the implementation:\n\n```bash\ngit clone https://github.com/polkadot-developers/revm-hardhat-examples.git\ncd zero-to-hero-dapp\n```"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 21, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 30580, "end_char": 31166, "estimated_token_count": 147, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Port Ethereum Projects to Polkadot Hub__\n\n ---\n\n Learn how to port an Ethereum project to Polkadot Hub using Hardhat and Viem.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/eth-dapps/uniswap-v2/)\n\n- Guide __Dive Deeper into Polkadot Precompiles__\n\n ---\n\n Learn how to use the Polkadot precompiles to interact with the blockchain.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/precompiles/)\n
"} {"page_id": "smart-contracts-cookbook-eth-dapps-uniswap-v2", "page_title": "Deploying Uniswap V2 on Polkadot", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 21, "end_char": 687, "estimated_token_count": 131, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nDecentralized exchanges (DEXs) are a cornerstone of the DeFi ecosystem, allowing for permissionless token swaps without intermediaries. [Uniswap V2](https://docs.uniswap.org/contracts/v2/overview){target=\\_blank}, with its Automated Market Maker (AMM) model, revolutionized DEXs by enabling liquidity provision for any ERC-20 token pair.\n\nThis tutorial will guide you through how Uniswap V2 works so you can take advantage of it in your projects deployed to Polkadot Hub. By understanding these contracts, you'll gain hands-on experience with one of the most influential DeFi protocols and understand how it functions across blockchain ecosystems."} {"page_id": "smart-contracts-cookbook-eth-dapps-uniswap-v2", "page_title": "Deploying Uniswap V2 on Polkadot", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 687, "end_char": 1160, "estimated_token_count": 115, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore starting, make sure you have:\n\n- Node.js (v16.0.0 or later) and npm installed.\n- Basic understanding of Solidity and JavaScript.\n- Familiarity with [Hardhat](/smart-contracts/dev-environments/hardhat/){target=\\_blank} development environment.\n- Some test tokens to cover transaction fees (obtained from the [Polkadot faucet](https://faucet.polkadot.io/?parachain=1111){target=\\_blank}).\n- Basic understanding of how AMMs and liquidity pools work."} {"page_id": "smart-contracts-cookbook-eth-dapps-uniswap-v2", "page_title": "Deploying Uniswap V2 on Polkadot", "index": 2, "depth": 2, "title": "Set Up the Project", "anchor": "set-up-the-project", "start_char": 1160, "end_char": 2905, "estimated_token_count": 417, "token_estimator": "heuristic-v1", "text": "## Set Up the Project\n\nStart by cloning the Uniswap V2 project:\n\n1. Clone the Uniswap V2 repository:\n\n ```\n git clone https://github.com/polkadot-developers/polkavm-hardhat-examples.git\n git checkout hardhat-polkadot-evm\n cd polkavm-hardhat-examples/uniswap-v2-polkadot/\n ```\n\n2. Install the required dependencies:\n\n ```bash\n npm install\n ```\n\n3. Create a `.env` file in your project root to store your private keys (you can use as an example the `env.example` file):\n\n ```text title=\".env\"\n LOCAL_PRIV_KEY=\"INSERT_LOCAL_PRIVATE_KEY\"\n AH_PRIV_KEY=\"INSERT_AH_PRIVATE_KEY\"\n ```\n\n Ensure to replace `\"INSERT_LOCAL_PRIVATE_KEY\"` with a private key available in the local environment (you can get them from this [file](https://github.com/paritytech/hardhat-polkadot/blob/main/packages/hardhat-polkadot-node/src/constants.ts#L21){target=\\_blank}). And `\"INSERT_AH_PRIVATE_KEY\"` with the account's private key you want to use to deploy the contracts. You can get this by exporting the private key from your wallet (e.g., MetaMask).\n\n !!!warning\n Keep your private key safe, and never share it with anyone. If it is compromised, your funds can be stolen.\n\n5. Compile the contracts:\n\n ```bash\n npx hardhat compile\n ```\n\nIf the compilation is successful, you should see the following output:\n\n
\n npx hardhat compile\n Compiling 12 Solidity files\n Successfully compiled 12 Solidity files\n
\n\nAfter running the above command, you should see the compiled contracts in the `artifacts` directory. This directory contains the ABI and bytecode of your contracts."} @@ -938,11 +924,11 @@ {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 40, "end_char": 394, "estimated_token_count": 69, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThis guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub TestNet using [Hardhat](https://hardhat.org/){target=\\_blank}, which provides a comprehensive development environment with built-in testing, debugging, and deployment capabilities. It's ideal for professional development workflows and team projects."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 394, "end_char": 930, "estimated_token_count": 154, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have the following:\n\n- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\\_blank} programming.\n- [Node.js](https://nodejs.org/en/download){target=\\_blank} v22.13.1 or later installed.\n- Test tokens for gas fees, available from the [Polkadot faucet](https://faucet.polkadot.io/){target=\\_blank}. See [Get Test Tokens](/smart-contracts/faucet/#get-test-tokens){target=\\_blank} for a guide to using the faucet.\n- A wallet with a private key for signing transactions."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 2, "depth": 2, "title": "Set Up Your Project", "anchor": "set-up-your-project", "start_char": 930, "end_char": 1148, "estimated_token_count": 49, "token_estimator": "heuristic-v1", "text": "## Set Up Your Project\n\nUse the following terminal commands to create a directory and initialize your Hardhat project inside of it:\n\n```bash\nmkdir hardhat-deployment\ncd hardhat-deployment\nnpx hardhat@^2.27.0 init\n```"} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 3, "depth": 2, "title": "Configure Hardhat", "anchor": "configure-hardhat", "start_char": 1148, "end_char": 2194, "estimated_token_count": 247, "token_estimator": "heuristic-v1", "text": "## Configure Hardhat\n\nOpen `hardhat.config.ts` and update to add `polkadotTestnet` to the `networks` configuration as highlighted in the following example code:\n\n```typescript title='hardhat.config.ts' hl_lines='19-23'\nimport type { HardhatUserConfig } from 'hardhat/config';\n\nimport hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem';\nimport { vars } from 'hardhat/config';\n\n\nconst config: HardhatUserConfig = {\n plugins: [hardhatToolboxViemPlugin],\n solidity: {\n version: '0.8.28',\n settings: {\n optimizer: {\n enabled: true,\n runs: 200,\n },\n },\n },\n networks: {\n polkadotTestnet: {\n url: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n chainId: 420420422,\n accounts: [vars.get('PRIVATE_KEY')],\n },\n },\n};\n\nexport default config;\n\n```\n\n!!! tip\n Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\\_blank} documentation to learn how to use Hardhat to handle your private keys securely."} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 4, "depth": 2, "title": "Create the Contract", "anchor": "create-the-contract", "start_char": 2194, "end_char": 2856, "estimated_token_count": 135, "token_estimator": "heuristic-v1", "text": "## Create the Contract\n\nFollow these steps to create your smart contract:\n\n1. Delete the default contract file(s) in the `contracts` directory.\n\n2. Create a new file named `Storage.sol` inside the `contracts` directory.\n\n3. Add the following code to create the `Storage.sol` smart contract:\n\n ```solidity title=\"Storage.sol\"\n // SPDX-License-Identifier: MIT\n pragma solidity ^0.8.9;\n\n contract Storage {\n uint256 private storedNumber;\n\n function store(uint256 num) public {\n storedNumber = num;\n }\n\n function retrieve() public view returns (uint256) {\n return storedNumber;\n }\n }\n\n ```"} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 5, "depth": 2, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 2856, "end_char": 3477, "estimated_token_count": 187, "token_estimator": "heuristic-v1", "text": "## Compile the Contract\n\nCompile your `Storage.sol` contract using the following command:\n\n```bash\nnpx hardhat compile\n```\n\nYou will see a message in the terminal confirming the contract was successfully compiled, similar to the following:\n\n
\n npx hardhat compile\n Downloading solc 0.8.28\n Downloading solc 0.8.28 (WASM build)\n Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun)\n \n
"} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 6, "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 3477, "end_char": 5384, "estimated_token_count": 474, "token_estimator": "heuristic-v1", "text": "## Deploy the Contract\n\nYou are now ready to deploy the contract to your chosen network. This example demonstrates deployment to the Polkadot TestNet. Deploy the contract as follows:\n\n1. Delete the default file(s) inside the `ignition/modules` directory.\n\n2. Create a new file named `Storage.ts` inside the `ignition/modules` directory.\n\n3. Open `ignition/modules/Storage.ts` and add the following code to create your deployment module:\n\n ```typescript title=\"ignition/modules/Storage.ts\"\n import { buildModule } from '@nomicfoundation/hardhat-ignition/modules';\n\n export default buildModule('StorageModule', (m) => {\n const storage = m.contract('Storage');\n return { storage };\n });\n\n ```\n\n4. Deploy your contract to Polkadot Hub TestNet using the following command:\n\n ```bash\n npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnet \n ```\n\n5. Confirm the target deployment network name and chain ID when prompted:\n\n
\n npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnet\n βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes\n  \n Hardhat Ignition πŸš€\n  \n Deploying [ StorageModule ]\n  \n [ StorageModule ] successfully deployed πŸš€\n  \n Deployed Addresses\n  \n Storage - 0x12345.....\n \n
\nCongratulations! You've now deployed a basic smart contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress."} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 7, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 5384, "end_char": 5979, "estimated_token_count": 161, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Deploy an ERC-20__\n\n ---\n\n Walk through deploying a fully-functional ERC-20 to the Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)\n\n- Guide __Deploy an NFT__\n\n ---\n\n Walk through deploying an NFT to the Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/)\n\n
"} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 3, "depth": 2, "title": "Configure Hardhat", "anchor": "configure-hardhat", "start_char": 1148, "end_char": 2192, "estimated_token_count": 243, "token_estimator": "heuristic-v1", "text": "## Configure Hardhat\n\nOpen `hardhat.config.ts` and update to add `polkadotTestnet` to the `networks` configuration as highlighted in the following example code:\n\n```typescript title='hardhat.config.ts' hl_lines='19-23'\nimport type { HardhatUserConfig } from 'hardhat/config';\n\nimport hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem';\nimport { vars } from 'hardhat/config';\n\n\nconst config: HardhatUserConfig = {\n plugins: [hardhatToolboxViemPlugin],\n solidity: {\n version: '0.8.28',\n settings: {\n optimizer: {\n enabled: true,\n runs: 200,\n },\n },\n },\n networks: {\n polkadotTestnet: {\n url: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n accounts: [vars.get('PRIVATE_KEY')],\n },\n },\n};\n\nexport default config;\n\n```\n\n!!! tip\n Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\\_blank} documentation to learn how to use Hardhat to handle your private keys securely."} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 4, "depth": 2, "title": "Create the Contract", "anchor": "create-the-contract", "start_char": 2192, "end_char": 2854, "estimated_token_count": 135, "token_estimator": "heuristic-v1", "text": "## Create the Contract\n\nFollow these steps to create your smart contract:\n\n1. Delete the default contract file(s) in the `contracts` directory.\n\n2. Create a new file named `Storage.sol` inside the `contracts` directory.\n\n3. Add the following code to create the `Storage.sol` smart contract:\n\n ```solidity title=\"Storage.sol\"\n // SPDX-License-Identifier: MIT\n pragma solidity ^0.8.9;\n\n contract Storage {\n uint256 private storedNumber;\n\n function store(uint256 num) public {\n storedNumber = num;\n }\n\n function retrieve() public view returns (uint256) {\n return storedNumber;\n }\n }\n\n ```"} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 5, "depth": 2, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 2854, "end_char": 3475, "estimated_token_count": 187, "token_estimator": "heuristic-v1", "text": "## Compile the Contract\n\nCompile your `Storage.sol` contract using the following command:\n\n```bash\nnpx hardhat compile\n```\n\nYou will see a message in the terminal confirming the contract was successfully compiled, similar to the following:\n\n
\n npx hardhat compile\n Downloading solc 0.8.28\n Downloading solc 0.8.28 (WASM build)\n Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun)\n \n
"} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 6, "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 3475, "end_char": 5382, "estimated_token_count": 474, "token_estimator": "heuristic-v1", "text": "## Deploy the Contract\n\nYou are now ready to deploy the contract to your chosen network. This example demonstrates deployment to the Polkadot TestNet. Deploy the contract as follows:\n\n1. Delete the default file(s) inside the `ignition/modules` directory.\n\n2. Create a new file named `Storage.ts` inside the `ignition/modules` directory.\n\n3. Open `ignition/modules/Storage.ts` and add the following code to create your deployment module:\n\n ```typescript title=\"ignition/modules/Storage.ts\"\n import { buildModule } from '@nomicfoundation/hardhat-ignition/modules';\n\n export default buildModule('StorageModule', (m) => {\n const storage = m.contract('Storage');\n return { storage };\n });\n\n ```\n\n4. Deploy your contract to Polkadot Hub TestNet using the following command:\n\n ```bash\n npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnet \n ```\n\n5. Confirm the target deployment network name and chain ID when prompted:\n\n
\n npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnet\n βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes\n  \n Hardhat Ignition πŸš€\n  \n Deploying [ StorageModule ]\n  \n [ StorageModule ] successfully deployed πŸš€\n  \n Deployed Addresses\n  \n Storage - 0x12345.....\n \n
\nCongratulations! You've now deployed a basic smart contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress."} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-hardhat", "page_title": "Deploy a Basic Contract with Hardhat", "index": 7, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 5382, "end_char": 5977, "estimated_token_count": 161, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Deploy an ERC-20__\n\n ---\n\n Walk through deploying a fully-functional ERC-20 to the Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)\n\n- Guide __Deploy an NFT__\n\n ---\n\n Walk through deploying an NFT to the Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/)\n\n
"} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-remix", "page_title": "Deploy a Basic Contract with Remix IDE", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 42, "end_char": 399, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThis guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub using [Remix IDE](https://remix.ethereum.org/){target=\\_blank}, which offers a visual, browser-based environment perfect for rapid prototyping and learning. It requires no local installation and provides an intuitive interface for contract development."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-remix", "page_title": "Deploy a Basic Contract with Remix IDE", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 399, "end_char": 961, "estimated_token_count": 160, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have the following:\n\n- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\\_blank} programming.\n- An EVM-compatible [wallet](/smart-contracts/connect/){target=\\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\\_blank}.\n- Test tokens for gas fees, available from the [Polkadot faucet](https://faucet.polkadot.io/){target=\\_blank}. See [Get Test Tokens](/smart-contracts/faucet/#get-test-tokens){target=\\_blank} for a guide to using the faucet."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-basic-basic-remix", "page_title": "Deploy a Basic Contract with Remix IDE", "index": 2, "depth": 2, "title": "Locate Your Contract", "anchor": "locate-your-contract", "start_char": 961, "end_char": 1479, "estimated_token_count": 129, "token_estimator": "heuristic-v1", "text": "## Locate Your Contract\n\nThis guide uses a default contract contract provided by Remix IDE. Follow these steps to locate the contract in Remix:\n\n1. Navigate to [Remix IDE](https://remix.ethereum.org/){target=\\_blank} in your web browser.\n\n2. Once the default workspace loads, locate the `contracts` folder. Inside `contracts`, locate the `Storage.sol` file which you will use as your sample contract throughout this guide.\n\n![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix/remix-01.webp)"} @@ -955,7 +941,7 @@ {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat", "page_title": "Deploy an ERC-20 Using Hardhat", "index": 3, "depth": 2, "title": "Configure Hardhat", "anchor": "configure-hardhat", "start_char": 2061, "end_char": 2964, "estimated_token_count": 232, "token_estimator": "heuristic-v1", "text": "## Configure Hardhat\n\nIf you started with the cloned Hardhat ERC-20 template, `hardhat.config.ts` is already configured to deploy to the Polkadot TestNet as shown in the example below:\n\n```ts title=\"hardhat.config.ts\" hl_lines=\"14-19\"\n\nconst config: HardhatUserConfig = {\n solidity: {\n version: \"0.8.28\",\n settings: {\n optimizer: {\n enabled: true,\n runs: 200,\n },\n },\n },\n networks: {\n polkadotTestnet: {\n url: vars.get(\"TESTNET_URL\", \"http://127.0.0.1:8545\"),\n accounts: vars.has(\"TESTNET_PRIVATE_KEY\") ? [vars.get(\"TESTNET_PRIVATE_KEY\")] : [],\n },\n },\n mocha: {\n timeout: 40000,\n },\n};\n\nexport default config;\n```\n\n!!! tip\n Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\\_blank} documentation to learn how to use Hardhat to handle your private keys securely."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat", "page_title": "Deploy an ERC-20 Using Hardhat", "index": 4, "depth": 2, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 2964, "end_char": 3197, "estimated_token_count": 44, "token_estimator": "heuristic-v1", "text": "## Compile the Contract \n\nNext, compile the contract included with the template by running the following command:\n\n```bash\nnpx hardhat compile\n```\n\nIf everything compiles successfully, you will see output similar to the following:"} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat", "page_title": "Deploy an ERC-20 Using Hardhat", "index": 5, "depth": 2, "title": "Test the Contract", "anchor": "test-the-contract", "start_char": 3197, "end_char": 5062, "estimated_token_count": 576, "token_estimator": "heuristic-v1", "text": "## Test the Contract\n\nYou can view the predefined test file at [`test/MyToken.test.ts`](https://github.com/polkadot-developers/revm-hardhat-examples/blob/master/erc20-hardhat/test/MyToken.test.ts){target=\\_blank}. This example test includes verification of the following:\n\n- The token name and symbol exist (confirms deployment) and are correct.\n- The token owner is correctly configured.\n- The initial token supply is zero.\n- The owner can mint tokens.\n- The total supply increases after a mint.\n- Successful mints to different test addresses with expected account balance and total supply changes.\n\nRun the tests using the following command:\n\n```bash\nnpx hardhat test --network polkadotTestnet\n```\n\nIf tests are successful, you will see outputs similar to the following:\n\n
\n npx hardhat test --network polkadotTestnet\n \n   MyToken\n     Deployment\n       βœ” Should have correct name and symbol\n       βœ” Should set the right owner\n       βœ” Should have zero initial supply\n     Minting\n       βœ” Should allow owner to mint tokens\n       βœ” Should increase total supply on mint\n     Multiple mints\n       βœ” Should correctly track balance after multiple mints\n \n   6 passing (369ms)\n \n
"} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat", "page_title": "Deploy an ERC-20 Using Hardhat", "index": 6, "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 5062, "end_char": 6719, "estimated_token_count": 425, "token_estimator": "heuristic-v1", "text": "## Deploy the Contract\n\nYou are now ready to deploy the contract to your chosen network. This example demonstrates deployment to the Polkadot TestNet. Deploy the contract as follows:\n\n1. Run the following command in your terminal:\n\n ```bash\n npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet\n ```\n\n2. Confirm the target deployment network name and chain ID when prompted:\n\n
\n npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet\n βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes\n  \n Hardhat Ignition πŸš€\n  \n Deploying [ TokenModule ]\n  \n Batch #1\n Executed TokenModule#MyToken\n  \n Batch #2\n Executed TokenModule#MyToken.mint\n  \n [ TokenModule ] successfully deployed πŸš€\n  \n Deployed Addresses\n  \n TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3\n \n
\n\nCongratulations! You've successfully deployed an ERC-20 token contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress."} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat", "page_title": "Deploy an ERC-20 Using Hardhat", "index": 6, "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 5062, "end_char": 6719, "estimated_token_count": 425, "token_estimator": "heuristic-v1", "text": "## Deploy the Contract\n\nYou are now ready to deploy the contract to your chosen network. This example demonstrates deployment to the Polkadot TestNet. Deploy the contract as follows:\n\n1. Run the following command in your terminal:\n\n ```bash\n npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet\n ```\n\n2. Confirm the target deployment network name and chain ID when prompted:\n\n
\n npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet\n βœ” Confirm deploy to network polkadotTestnet (420420417)? … yes\n  \n Hardhat Ignition πŸš€\n  \n Deploying [ TokenModule ]\n  \n Batch #1\n Executed TokenModule#MyToken\n  \n Batch #2\n Executed TokenModule#MyToken.mint\n  \n [ TokenModule ] successfully deployed πŸš€\n  \n Deployed Addresses\n  \n TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3\n \n
\n\nCongratulations! You've successfully deployed an ERC-20 token contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-hardhat", "page_title": "Deploy an ERC-20 Using Hardhat", "index": 7, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6719, "end_char": 7318, "estimated_token_count": 161, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Deploy an NFT__\n\n ---\n\n Walk through deploying an NFT to the Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/)\n\n- Guide __Create a DApp__\n\n ---\n\n Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)\n\n
"} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-remix", "page_title": "Deploy an ERC-20 Using Remix IDE", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 36, "end_char": 778, "estimated_token_count": 187, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[ERC-20](https://eips.ethereum.org/EIPS/eip-20){target=\\_blank} tokens are fungible tokens commonly used for creating cryptocurrencies, governance tokens, and staking mechanisms. Polkadot Hub enables easy token deployment with Ethereum-compatible smart contracts and tools via the EVM backend.\n\nThis tutorial covers deploying an ERC-20 contract on Polkadot Hub TestNet using [Remix IDE](https://remix.ethereum.org/){target=\\_blank}, a web-based development tool. The ERC-20 contract can be retrieved from OpenZeppelin's [GitHub repository](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v5.4.0/contracts/token/ERC20){target=\\_blank} or their [Contract Wizard](https://wizard.openzeppelin.com/){target=\\_blank}."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-remix", "page_title": "Deploy an ERC-20 Using Remix IDE", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 778, "end_char": 1434, "estimated_token_count": 194, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have:\n\n- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\\_blank} programming and [ERC-20](https://ethereum.org/developers/docs/standards/tokens/erc-20/){target=\\_blank} fungible tokens.\n- An EVM-compatible [wallet](/smart-contracts/connect/){target=\\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\\_blank}.\n- Test tokens for gas fees, available from the [Polkadot faucet](https://faucet.polkadot.io/){target=\\_blank}. See [Get Test Tokens](/smart-contracts/faucet/#get-test-tokens){target=\\_blank} for a guide to using the faucet."} @@ -975,11 +961,11 @@ {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 35, "end_char": 853, "estimated_token_count": 192, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nNon-Fungible Tokens (NFTs) represent unique digital assets commonly used for digital art, collectibles, gaming, and identity verification.\n\nThis guide demonstrates how to deploy an [ERC-721](https://eips.ethereum.org/EIPS/eip-721){target=\\_blank} NFT contract to [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\\_blank} TestNet. You'll use OpenZeppelin's battle-tested [NFT implementation](https://github.com/OpenZeppelin/openzeppelin-contracts){target=\\_blank} and [Hardhat](https://hardhat.org/docs/getting-started){target=\\_blank}, a comprehensive development environment with built-in testing, debugging, and deployment capabilities. Hardhat uses standard Solidity compilation to generate EVM bytecode, making it fully compatible with Polkadot Hub's EVM environment."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 853, "end_char": 1503, "estimated_token_count": 192, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have the following:\n\n- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\\_blank} programming and [ERC-721](https://ethereum.org/developers/docs/standards/tokens/erc-721/){target=\\_blank} non-fungible tokens.\n- [Node.js](https://nodejs.org/en/download){target=\\_blank} v22.13.1 or later installed.\n- Test tokens for gas fees, available from the [Polkadot faucet](https://faucet.polkadot.io/){target=\\_blank}. See [Get Test Tokens](/smart-contracts/faucet/#get-test-tokens){target=\\_blank} for a guide to using the faucet.\n- A wallet with a private key for signing transactions."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 2, "depth": 2, "title": "Set Up Your Project", "anchor": "set-up-your-project", "start_char": 1503, "end_char": 1883, "estimated_token_count": 79, "token_estimator": "heuristic-v1", "text": "## Set Up Your Project\n\n1. Use the following terminal commands to create a directory and initialize your Hardhat project inside of it:\n\n ```bash\n mkdir hardhat-nft-deployment\n cd hardhat-nft-deployment\n npx hardhat@^2.27.0 init\n ```\n\n2. Install the OpenZeppelin contract dependencies using the command:\n\n ```bash\n npm install @openzeppelin/contracts\n ```"} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 3, "depth": 2, "title": "Configure Hardhat", "anchor": "configure-hardhat", "start_char": 1883, "end_char": 2927, "estimated_token_count": 247, "token_estimator": "heuristic-v1", "text": "## Configure Hardhat\n\nOpen `hardhat.config.ts` and update to add `polkadotTestnet` to the `networks` configuration as highlighted in the following example code:\n\n```typescript title=\"hardhat.config.ts\" hl_lines='18-23'\nimport type { HardhatUserConfig } from 'hardhat/config';\n\nimport hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem';\nimport { vars } from 'hardhat/config';\n\nconst config: HardhatUserConfig = {\n plugins: [hardhatToolboxViemPlugin],\n solidity: {\n version: '0.8.28',\n settings: {\n optimizer: {\n enabled: true,\n runs: 200,\n },\n },\n },\n networks: {\n polkadotTestnet: {\n url: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n chainId: 420420422,\n accounts: [vars.get('PRIVATE_KEY')],\n },\n },\n};\n\nexport default config;\n```\n\n!!! tip\n Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\\_blank} documentation to learn how to use Hardhat to handle your private keys securely."} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 4, "depth": 2, "title": "Create the Contract", "anchor": "create-the-contract", "start_char": 2927, "end_char": 3803, "estimated_token_count": 188, "token_estimator": "heuristic-v1", "text": "## Create the Contract\n\nFollow these steps to create your smart contract:\n\n1. Delete the default contract file(s) in the `contracts` directory.\n\n2. Create a new file named `MyNFT.sol` inside the `contracts` directory.\n\n3. Add the following code to create the `MyNFT.sol` smart contract:\n ```solidity title=\"contracts/MyNFT.sol\"\n // SPDX-License-Identifier: MIT\n pragma solidity ^0.8.20;\n\n import \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n import \"@openzeppelin/contracts/access/Ownable.sol\";\n\n contract MyNFT is ERC721, Ownable {\n uint256 private _nextTokenId;\n\n constructor(\n address initialOwner\n ) ERC721(\"MyToken\", \"MTK\") Ownable(initialOwner) {}\n\n function safeMint(address to) public onlyOwner {\n uint256 tokenId = _nextTokenId++;\n _safeMint(to, tokenId);\n }\n }\n\n ```"} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 5, "depth": 2, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 3803, "end_char": 4421, "estimated_token_count": 187, "token_estimator": "heuristic-v1", "text": "## Compile the Contract\n\nCompile your `MyNFT.sol` contract using the following command:\n\n```bash\nnpx hardhat compile\n```\n\nYou will see a message in the terminal confirming the contract was successfully compiled, similar to the following:\n\n
\n npx hardhat compile\n Downloading solc 0.8.28\n Downloading solc 0.8.28 (WASM build)\n Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun)\n \n
"} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 6, "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 4421, "end_char": 6756, "estimated_token_count": 592, "token_estimator": "heuristic-v1", "text": "## Deploy the Contract\n\nYou are now ready to deploy the contract to your chosen network. This example demonstrates deployment to the Polkadot TestNet. Deploy the contract as follows:\n\n1. Delete the default file(s) inside the `ignition/modules` directory.\n\n2. Create a new file named `MyNFT.ts` inside the `ignition/modules` directory.\n\n3. Open `ignition/modules/MyNFT.ts` and add the following code to create your deployment module:\n ```typescript title=\"ignition/modules/MyNFT.ts\"\n import { buildModule } from '@nomicfoundation/hardhat-ignition/modules';\n\n export default buildModule('MyNFTModule', (m) => {\n const initialOwner = m.getParameter('initialOwner', 'INSERT_OWNER_ADDRESS');\n const myNFT = m.contract('MyNFT', [initialOwner]);\n return { myNFT };\n });\n\n ```\n\n Replace `INSERT_OWNER_ADDRESS` with your desired owner address.\n\n4. Deploy your contract to Polkadot Hub TestNet using the following command:\n\n ```bash\n npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotTestnet\n ```\n\n5. Confirm the target deployment network name and chain ID when prompted:\n\n
\n npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestnet\n βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes\n  \n Hardhat Ignition πŸš€\n  \n Deploying [ MyNFTModule ]\n  \n Batch #1\n Executed MyNFTModule#MyNFT\n  \n Batch #2\n Executed MyNFTModule#MyNFT.safeMint\n  \n [ TokenModule ] successfully deployed πŸš€\n  \n Deployed Addresses\n  \n MyNFTModule#MyNFT - 0x1234.......\n \n
\nCongratulations! You've successfully deployed an ERC-721 NFT contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress."} -{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 7, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6756, "end_char": 7377, "estimated_token_count": 167, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Deploy an ERC-20__\n\n ---\n\n Walk through deploying a fully-functional ERC-20 to Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)\n\n- Guide __Create a DApp__\n\n ---\n\n Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)\n\n
"} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 3, "depth": 2, "title": "Configure Hardhat", "anchor": "configure-hardhat", "start_char": 1883, "end_char": 2925, "estimated_token_count": 243, "token_estimator": "heuristic-v1", "text": "## Configure Hardhat\n\nOpen `hardhat.config.ts` and update to add `polkadotTestnet` to the `networks` configuration as highlighted in the following example code:\n\n```typescript title=\"hardhat.config.ts\" hl_lines='18-23'\nimport type { HardhatUserConfig } from 'hardhat/config';\n\nimport hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem';\nimport { vars } from 'hardhat/config';\n\nconst config: HardhatUserConfig = {\n plugins: [hardhatToolboxViemPlugin],\n solidity: {\n version: '0.8.28',\n settings: {\n optimizer: {\n enabled: true,\n runs: 200,\n },\n },\n },\n networks: {\n polkadotTestnet: {\n url: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n accounts: [vars.get('PRIVATE_KEY')],\n },\n },\n};\n\nexport default config;\n```\n\n!!! tip\n Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\\_blank} documentation to learn how to use Hardhat to handle your private keys securely."} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 4, "depth": 2, "title": "Create the Contract", "anchor": "create-the-contract", "start_char": 2925, "end_char": 3801, "estimated_token_count": 188, "token_estimator": "heuristic-v1", "text": "## Create the Contract\n\nFollow these steps to create your smart contract:\n\n1. Delete the default contract file(s) in the `contracts` directory.\n\n2. Create a new file named `MyNFT.sol` inside the `contracts` directory.\n\n3. Add the following code to create the `MyNFT.sol` smart contract:\n ```solidity title=\"contracts/MyNFT.sol\"\n // SPDX-License-Identifier: MIT\n pragma solidity ^0.8.20;\n\n import \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n import \"@openzeppelin/contracts/access/Ownable.sol\";\n\n contract MyNFT is ERC721, Ownable {\n uint256 private _nextTokenId;\n\n constructor(\n address initialOwner\n ) ERC721(\"MyToken\", \"MTK\") Ownable(initialOwner) {}\n\n function safeMint(address to) public onlyOwner {\n uint256 tokenId = _nextTokenId++;\n _safeMint(to, tokenId);\n }\n }\n\n ```"} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 5, "depth": 2, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 3801, "end_char": 4419, "estimated_token_count": 187, "token_estimator": "heuristic-v1", "text": "## Compile the Contract\n\nCompile your `MyNFT.sol` contract using the following command:\n\n```bash\nnpx hardhat compile\n```\n\nYou will see a message in the terminal confirming the contract was successfully compiled, similar to the following:\n\n
\n npx hardhat compile\n Downloading solc 0.8.28\n Downloading solc 0.8.28 (WASM build)\n Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun)\n \n
"} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 6, "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 4419, "end_char": 6754, "estimated_token_count": 592, "token_estimator": "heuristic-v1", "text": "## Deploy the Contract\n\nYou are now ready to deploy the contract to your chosen network. This example demonstrates deployment to the Polkadot TestNet. Deploy the contract as follows:\n\n1. Delete the default file(s) inside the `ignition/modules` directory.\n\n2. Create a new file named `MyNFT.ts` inside the `ignition/modules` directory.\n\n3. Open `ignition/modules/MyNFT.ts` and add the following code to create your deployment module:\n ```typescript title=\"ignition/modules/MyNFT.ts\"\n import { buildModule } from '@nomicfoundation/hardhat-ignition/modules';\n\n export default buildModule('MyNFTModule', (m) => {\n const initialOwner = m.getParameter('initialOwner', 'INSERT_OWNER_ADDRESS');\n const myNFT = m.contract('MyNFT', [initialOwner]);\n return { myNFT };\n });\n\n ```\n\n Replace `INSERT_OWNER_ADDRESS` with your desired owner address.\n\n4. Deploy your contract to Polkadot Hub TestNet using the following command:\n\n ```bash\n npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotTestnet\n ```\n\n5. Confirm the target deployment network name and chain ID when prompted:\n\n
\n npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestnet\n βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes\n  \n Hardhat Ignition πŸš€\n  \n Deploying [ MyNFTModule ]\n  \n Batch #1\n Executed MyNFTModule#MyNFT\n  \n Batch #2\n Executed MyNFTModule#MyNFT.safeMint\n  \n [ TokenModule ] successfully deployed πŸš€\n  \n Deployed Addresses\n  \n MyNFTModule#MyNFT - 0x1234.......\n \n
\nCongratulations! You've successfully deployed an ERC-721 NFT contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress."} +{"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-hardhat", "page_title": "Deploy an ERC-721 Using Hardhat", "index": 7, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6754, "end_char": 7375, "estimated_token_count": 167, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Deploy an ERC-20__\n\n ---\n\n Walk through deploying a fully-functional ERC-20 to Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)\n\n- Guide __Create a DApp__\n\n ---\n\n Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)\n\n
"} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-remix", "page_title": "Deploy an ERC-721 NFT Using Remix", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 28, "end_char": 763, "estimated_token_count": 178, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nNon-Fungible Tokens (NFTs) represent unique digital assets commonly used for digital art, collectibles, gaming, and identity verification.\n\nThis guide demonstrates how to deploy an [ERC-721](https://eips.ethereum.org/EIPS/eip-721){target=\\_blank} NFT contract to [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\\_blank}. You'll use [OpenZeppelin's battle-tested NFT implementation](https://github.com/OpenZeppelin/openzeppelin-contracts){target=\\_blank} and [Remix](https://remix.ethereum.org/){target=\\_blank}, a visual, browser-based environment perfect for rapid prototyping and learning. It requires no local installation and provides an intuitive interface for contract development."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-remix", "page_title": "Deploy an ERC-721 NFT Using Remix", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 763, "end_char": 1368, "estimated_token_count": 181, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\n- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\\_blank} programming and [ERC-721 NFT](https://ethereum.org/developers/docs/standards/tokens/erc-721/) standards.\n- An EVM-compatible [wallet](/smart-contracts/connect/){target=\\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\\_blank}.\n- Test tokens for gas fees (available from the [Polkadot faucet](https://faucet.polkadot.io/){target=\\_blank}). See [Get Test Tokens](/smart-contracts/faucet/#get-test-tokens){target=\\_blank} for a guide to using the faucet."} {"page_id": "smart-contracts-cookbook-smart-contracts-deploy-nft-nft-remix", "page_title": "Deploy an ERC-721 NFT Using Remix", "index": 2, "depth": 2, "title": "Create Your Contract", "anchor": "create-your-contract", "start_char": 1368, "end_char": 2563, "estimated_token_count": 289, "token_estimator": "heuristic-v1", "text": "## Create Your Contract\n\nFollow the steps below to create the ERC-721 contract:\n\n1. Navigate to [Remix IDE](https://remix.ethereum.org/){target=\\_blank} in your web browser.\n2. Select the **Create new file** button under the **contracts** folder, and name your contract `MyNFT.sol`.\n\n ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-01.webp)\n\n3. Now, paste the following ERC-721 contract code into `MyNFT.sol`:\n\n ```solidity title=\"contracts/MyNFT.sol\"\n // SPDX-License-Identifier: MIT\n pragma solidity ^0.8.20;\n\n import \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n import \"@openzeppelin/contracts/access/Ownable.sol\";\n\n contract MyNFT is ERC721, Ownable {\n uint256 private _nextTokenId;\n\n constructor(\n address initialOwner\n ) ERC721(\"MyToken\", \"MTK\") Ownable(initialOwner) {}\n\n function safeMint(address to) public onlyOwner {\n uint256 tokenId = _nextTokenId++;\n _safeMint(to, tokenId);\n }\n }\n\n ```\n\n !!! tip\n The [OpenZeppelin Contracts Wizard](https://wizard.openzeppelin.com/){target=\\_blank} was used to generate this example ERC-721 contract."} @@ -992,8 +978,8 @@ {"page_id": "smart-contracts-dev-environments-hardhat", "page_title": "Use Hardhat with Polkadot Hub", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 11, "end_char": 386, "estimated_token_count": 75, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[Hardhat](https://hardhat.org/){target=\\_blank} is a flexible development environment for building, testing, and deploying smart contracts on Polkadot. Its task runner and plugin system support organizing contract code, running tests, managing deployments, and adding custom tooling. This page demonstrates how to set up a Hardhat project for Polkadot Hub."} {"page_id": "smart-contracts-dev-environments-hardhat", "page_title": "Use Hardhat with Polkadot Hub", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 386, "end_char": 767, "estimated_token_count": 129, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore setting up Hardhat, make sure the following are installed:\n\n- [Node.js](https://nodejs.org/){target=\\_blank} (Hardhat requires an LTS Node version, even major numbers like 18.x, 20.x, or 22.x)\n- A package manager like [npm](https://www.npmjs.com/){target=\\_blank}, [pnpm](https://pnpm.io/){target=\\_blank}, or [yarn](https://yarnpkg.com/){target=\\_blank}"} {"page_id": "smart-contracts-dev-environments-hardhat", "page_title": "Use Hardhat with Polkadot Hub", "index": 2, "depth": 2, "title": "Initialize a Hardhat Project", "anchor": "initialize-a-hardhat-project", "start_char": 767, "end_char": 2605, "estimated_token_count": 382, "token_estimator": "heuristic-v1", "text": "## Initialize a Hardhat Project\n\n1. Create a directory to hold your project files:\n\n ```bash\n mkdir hardhat-example\n cd hardhat-example\n ```\n\n2. Initialize a Hardhat project:\n\n === \"npm\"\n\n This single command sets up your project, installs Hardhat (and optionally the Toolbox), and intializes the project:\n\n ```bash\n npx hardhat@^2.27.0 init\n ```\n\n === \"pnpm\"\n\n This single command sets up your project, installs Hardhat (and optionally the Toolbox), and intializes the project:\n\n ```bash\n pnpm dlx hardhat@^2.27.0 init\n ```\n\n === \"yarn\"\n\n These commands manually set up your project, install Hardhat (and optionally the Toolbox), and initializes the project:\n\n ```bash\n # Initialize a new Node.js project\n yarn init -y\n\n # Install Hardhat and the Hardhat Toolbox locally\n yarn add --dev hardhat@^2.27.0 @nomicfoundation/hardhat-toolbox\n\n # Initialize a Hardhat project\n npx hardhat init\n ```\n\n3. You will be prompted to select certain configurations for your project. To quickly create a working setup, you can accept the default answers, which will create a JavaScript project, initialize it in the current directory, add a `.gitignore`, and install all dependencies.\n\nAfter completing the setup, your Hardhat project will be fully initialized with all necessary files and dependencies. You'll see the following core components in your project:\n\n- **`contracts`**: Stores your Solidity smart contracts.\n- **`ignition`**: Contains deployment modules for safely deploying your contracts to various networks.\n- **`test`**: Contains test files that validate contract functionality.\n- **`hardhat.config.js | .ts`**: Defines your project's settings, including networks, compiler options, and plugins."} -{"page_id": "smart-contracts-dev-environments-hardhat", "page_title": "Use Hardhat with Polkadot Hub", "index": 3, "depth": 2, "title": "Configure Hardhat for Polkadot Hub", "anchor": "configure-hardhat-for-polkadot-hub", "start_char": 2605, "end_char": 3669, "estimated_token_count": 250, "token_estimator": "heuristic-v1", "text": "## Configure Hardhat for Polkadot Hub\n\nTo use Hardhat with Polkadot Hub, define the network configuration in your `hardhat.config.ts` file:\n\n=== \"Polkadot TestNet\"\n\n ```ts title='hardhat.config.ts'\n import type { HardhatUserConfig } from 'hardhat/config';\n import '@nomicfoundation/hardhat-toolbox';\n\n // If you want to use a variable for your private key\n import { vars } from 'hardhat/config';\n\n const config: HardhatUserConfig = {\n solidity: '0.8.28',\n networks: {\n polkadotTestnet: {\n url: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n chainId: 420420422,\n accounts: [vars.get('PRIVATE_KEY')],\n },\n },\n };\n\n export default config;\n ```\n\n!!! tip\n\n To define a [configuration variable](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\\_blank} for your private key, run:\n\n ```bash\n npx hardhat vars set PRIVATE_KEY\n ```\n\n Hardhat will prompt you to enter your private key and store it so it can be referenced in your configuration file."} -{"page_id": "smart-contracts-dev-environments-hardhat", "page_title": "Use Hardhat with Polkadot Hub", "index": 4, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 3669, "end_char": 4828, "estimated_token_count": 308, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Deploy a Basic Contract__\n\n ---\n\n Ready to start using Hardhat? Learn how to compile, test, and deploy a basic contract.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/)\n\n- Guide __Deploy an ERC-20__\n\n ---\n\n Walk through deploying a fully-functional ERC-20 to Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)\n\n- Guide __Deploy an NFT__\n\n ---\n\n Walk through deploying an NFT to Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/)\n\n- Guide __Create a DApp__\n\n ---\n\n Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)\n\n
"} +{"page_id": "smart-contracts-dev-environments-hardhat", "page_title": "Use Hardhat with Polkadot Hub", "index": 3, "depth": 2, "title": "Configure Hardhat for Polkadot Hub", "anchor": "configure-hardhat-for-polkadot-hub", "start_char": 2605, "end_char": 3679, "estimated_token_count": 246, "token_estimator": "heuristic-v1", "text": "## Configure Hardhat for Polkadot Hub\n\nTo use Hardhat with Polkadot Hub, define the network configuration in your `hardhat.config.ts` file:\n\n=== \"Polkadot TestNet\"\n\n ```ts title='hardhat.config.ts'\n import type { HardhatUserConfig } from 'hardhat/config';\n import '@nomicfoundation/hardhat-toolbox';\n\n // If you want to use a variable for your private key\n import { vars } from 'hardhat/config';\n\n const config: HardhatUserConfig = {\n solidity: '0.8.28',\n networks: {\n polkadotTestnet: {\n url: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n accounts: [vars.get('PRIVATE_KEY')],\n },\n },\n };\n\n export default config;\n ```\n\n!!! tip\n\n To define a [configuration variable](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\\_blank} for your private key, run:\n\n ```bash\n npx hardhat vars set PRIVATE_KEY\n ```\n\n Hardhat will prompt you to enter your private key and store it so it can be referenced in your configuration file."} +{"page_id": "smart-contracts-dev-environments-hardhat", "page_title": "Use Hardhat with Polkadot Hub", "index": 4, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 3679, "end_char": 4838, "estimated_token_count": 308, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Deploy a Basic Contract__\n\n ---\n\n Ready to start using Hardhat? Learn how to compile, test, and deploy a basic contract.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/)\n\n- Guide __Deploy an ERC-20__\n\n ---\n\n Walk through deploying a fully-functional ERC-20 to Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)\n\n- Guide __Deploy an NFT__\n\n ---\n\n Walk through deploying an NFT to Polkadot Hub using Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/)\n\n- Guide __Create a DApp__\n\n ---\n\n Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)\n\n
"} {"page_id": "smart-contracts-dev-environments-local-dev-node", "page_title": "Local Development Node", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 26, "end_char": 529, "estimated_token_count": 97, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nA local development node provides an isolated blockchain environment where you can deploy, test, and debug smart contracts without incurring network fees or waiting for block confirmations. This guide demonstrates how to set up a local Polkadot SDK-based node with smart contract capabilities.\n\nBy the end of this guide, you'll have:\n\n- A running node with smart contract support.\n- An ETH-RPC adapter for Ethereum-compatible tooling integration accessible at `http://localhost:8545`."} {"page_id": "smart-contracts-dev-environments-local-dev-node", "page_title": "Local Development Node", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 529, "end_char": 858, "estimated_token_count": 76, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore getting started, ensure you have done the following:\n\n- Completed the [Install Polkadot SDK Dependencies](/parachains/install-polkadot-sdk/){target=\\_blank} guide and successfully installed [Rust](https://rust-lang.org/){target=\\_blank} and the required packages to set up your development environment."} {"page_id": "smart-contracts-dev-environments-local-dev-node", "page_title": "Local Development Node", "index": 2, "depth": 2, "title": "Install the Revive Dev Node and ETH-RPC Adapter", "anchor": "install-the-revive-dev-node-and-eth-rpc-adapter", "start_char": 858, "end_char": 2337, "estimated_token_count": 340, "token_estimator": "heuristic-v1", "text": "## Install the Revive Dev Node and ETH-RPC Adapter\n\nThe Polkadot SDK repository contains both the [Revive Dev node](https://github.com/paritytech/polkadot-sdk/tree/8e2b6f742a38bb13688e12abacded0aab2dbbb23/substrate/frame/revive/dev-node){target=\\_blank} implementation and the [ETH-RPC adapter](https://github.com/paritytech/polkadot-sdk/tree/8e2b6f742a38bb13688e12abacded0aab2dbbb23/substrate/frame/revive/rpc){target=\\_blank} required for Ethereum compatibility. Start by cloning the repository and navigating to the project directory:\n\n```bash\ngit clone https://github.com/paritytech/polkadot-sdk.git\ncd polkadot-sdk\n```\n\nNext, you need to compile the two essential components for your development environment. The Substrate node provides the core blockchain runtime with smart contract support, while the ETH-RPC adapter enables Ethereum JSON-RPC compatibility for existing tooling:\n\n```bash\ncargo build -p revive-dev-node --bin revive-dev-node --release\ncargo build -p pallet-revive-eth-rpc --bin eth-rpc --release\n```\n\nThe compilation process may take some time depending on your system specifications, potentially up to 30 minutes. Release builds are optimized for performance but take longer to compile than debug builds. After successful compilation, you can verify the binaries are available in the `target/release` directory:\n\n- **Revive Dev node path**: `polkadot-sdk/target/release/revive-dev-node`\n- **ETH-RPC adapter path**: `polkadot-sdk/target/release/eth-rpc`"} @@ -1005,11 +991,11 @@ {"page_id": "smart-contracts-dev-environments-remix", "page_title": "Use the Remix IDE on Polkadot Hub", "index": 4, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 3336, "end_char": 4200, "estimated_token_count": 234, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Deploy a Basic Contract__\n\n ---\n\n Ready to start using Remix? Learn how to compile, test, and deploy a basic contract.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix/)\n\n- Guide __Deploy an ERC-20__\n\n ---\n\n Walk through deploying a fully-functional ERC-20 to Polkadot Hub using Remix.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/)\n\n- Guide __Deploy an NFT__\n\n ---\n\n Walk through deploying an NFT to Polkadot Hub using Remix.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/)\n\n
"} {"page_id": "smart-contracts-explorers", "page_title": "Block Explorers", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 19, "end_char": 327, "estimated_token_count": 49, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nBlock explorers serve as comprehensive blockchain analytics platforms that provide access to on-chain data. These web applications function as search engines for blockchain networks, allowing users to query, visualize, and analyze blockchain data in real time through intuitive interfaces."} {"page_id": "smart-contracts-explorers", "page_title": "Block Explorers", "index": 1, "depth": 2, "title": "Core Functionality", "anchor": "core-functionality", "start_char": 327, "end_char": 1017, "estimated_token_count": 139, "token_estimator": "heuristic-v1", "text": "## Core Functionality\n\nThese block explorers provide essential capabilities for interacting with smart contracts in Polkadot Hub:\n\n- **Transaction tracking**: Monitor transaction status, confirmations, fees, and metadata.\n- **Address analysis**: View account balances, transaction history, and associated contracts.\n- **Block information**: Examine block contents.\n- **Smart contract interaction**: Review contract code, verification status, and interaction history.\n- **Token tracking**: Monitor ERC-20, ERC-721, and other token standards with transfer history and holder analytics.\n- **Network statistics**: Access metrics on transaction volume, gas usage, and other network parameters."} -{"page_id": "smart-contracts-explorers", "page_title": "Block Explorers", "index": 2, "depth": 2, "title": "Available Block Explorers", "anchor": "available-block-explorers", "start_char": 1017, "end_char": 1229, "estimated_token_count": 30, "token_estimator": "heuristic-v1", "text": "## Available Block Explorers\n\nThe following block explorers are available for PolkaVM smart contracts, providing specialized tools for monitoring and analyzing contract activity within the Polkadot ecosystem."} -{"page_id": "smart-contracts-explorers", "page_title": "Block Explorers", "index": 3, "depth": 3, "title": "BlockScout", "anchor": "blockscout", "start_char": 1229, "end_char": 1618, "estimated_token_count": 89, "token_estimator": "heuristic-v1", "text": "### BlockScout\n\nBlockScout is an open-source explorer platform with a user-friendly interface adapted for PolkaVM contracts. It excels at detailed contract analytics and provides developers with comprehensive API access.\n\n- [Polkadot Hub TestNet BlockScout](https://blockscout-passet-hub.parity-testnet.parity.io/){target=\\_blank}\n\n![](/images/smart-contracts/explorers/explorers-01.webp)"} -{"page_id": "smart-contracts-faucet", "page_title": "Get Tokens from the Official Faucet", "index": 0, "depth": 2, "title": "Get Test Tokens", "anchor": "get-test-tokens", "start_char": 473, "end_char": 1160, "estimated_token_count": 182, "token_estimator": "heuristic-v1", "text": "## Get Test Tokens\n\nFor Polkadot Hub TestNet, you can use the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\\_blank} to obtain test tokens. Here's how to do it:\n\n1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\\_blank}. If the desired network is not already selected, choose it from the **Network** drop-down. This example uses the Polkadot Hub TestNet.\n2. Copy your address linked to the TestNet and paste it into the designated field.\n3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly.\n\n![Polkadot Faucet](/images/smart-contracts/faucet/faucet-1.gif)"} -{"page_id": "smart-contracts-faucet", "page_title": "Get Tokens from the Official Faucet", "index": 1, "depth": 2, "title": "Things to Consider", "anchor": "things-to-consider", "start_char": 1160, "end_char": 1584, "estimated_token_count": 79, "token_estimator": "heuristic-v1", "text": "## Things to Consider\n\n!!! info \"Rate Limiting\"\n Faucets typically implement rate limiting to prevent abuse. You may need to wait between requests if you've recently obtained tokens from the same faucet.\n\n!!! warning \"Network Compatibility\"\n Ensure your wallet is connected to the correct network (Polkadot Hub TestNet) before requesting tokens. Tokens sent to addresses on different networks will not be accessible."} -{"page_id": "smart-contracts-faucet", "page_title": "Get Tokens from the Official Faucet", "index": 2, "depth": 2, "title": "Using Your Test Tokens", "anchor": "using-your-test-tokens", "start_char": 1584, "end_char": 1890, "estimated_token_count": 52, "token_estimator": "heuristic-v1", "text": "## Using Your Test Tokens\n\nGetting started with test tokens is the first step in your Polkadot development journey. These free resources enable you to build, experiment with, and refine your applications without financial constraints, ensuring your projects are robust and ready for deployment on MainNet."} +{"page_id": "smart-contracts-explorers", "page_title": "Block Explorers", "index": 2, "depth": 2, "title": "Available Block Explorers", "anchor": "available-block-explorers", "start_char": 1017, "end_char": 1231, "estimated_token_count": 30, "token_estimator": "heuristic-v1", "text": "## Available Block Explorers\n\nThe following block explorers are available for PolkaVM smart contracts, providing specialized tools for monitoring and analyzing contract activity within the Polkadot ecosystem."} +{"page_id": "smart-contracts-explorers", "page_title": "Block Explorers", "index": 3, "depth": 3, "title": "Routescan", "anchor": "routescan", "start_char": 1231, "end_char": 1442, "estimated_token_count": 45, "token_estimator": "heuristic-v1", "text": "### Routescan\n\nRoutescan delivers multi-chain explorer capabilities with specialized support for PolkaVM environments.\n\n- [Polkadot Hub TestNet Routescan](https://polkadot.testnet.routescan.io/){target=\\_blank}"} +{"page_id": "smart-contracts-faucet", "page_title": "Get Tokens from the Official Faucet", "index": 0, "depth": 2, "title": "Get Test Tokens", "anchor": "get-test-tokens", "start_char": 473, "end_char": 1131, "estimated_token_count": 174, "token_estimator": "heuristic-v1", "text": "## Get Test Tokens\n\nFor Polkadot Hub TestNet, you can use the [Polkadot Faucet](https://faucet.polkadot.io/){target=\\_blank} to obtain test tokens. Here's how to do it:\n\n1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/){target=\\_blank}. If the desired network is not already selected, choose it from the **Network** drop-down. This example uses the Polkadot Hub TestNet.\n2. Copy your address linked to the TestNet and paste it into the designated field.\n3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly.\n\n![Polkadot Faucet](/images/smart-contracts/faucet/faucet-01.gif)"} +{"page_id": "smart-contracts-faucet", "page_title": "Get Tokens from the Official Faucet", "index": 1, "depth": 2, "title": "Things to Consider", "anchor": "things-to-consider", "start_char": 1131, "end_char": 1555, "estimated_token_count": 79, "token_estimator": "heuristic-v1", "text": "## Things to Consider\n\n!!! info \"Rate Limiting\"\n Faucets typically implement rate limiting to prevent abuse. You may need to wait between requests if you've recently obtained tokens from the same faucet.\n\n!!! warning \"Network Compatibility\"\n Ensure your wallet is connected to the correct network (Polkadot Hub TestNet) before requesting tokens. Tokens sent to addresses on different networks will not be accessible."} +{"page_id": "smart-contracts-faucet", "page_title": "Get Tokens from the Official Faucet", "index": 2, "depth": 2, "title": "Using Your Test Tokens", "anchor": "using-your-test-tokens", "start_char": 1555, "end_char": 1861, "estimated_token_count": 52, "token_estimator": "heuristic-v1", "text": "## Using Your Test Tokens\n\nGetting started with test tokens is the first step in your Polkadot development journey. These free resources enable you to build, experiment with, and refine your applications without financial constraints, ensuring your projects are robust and ready for deployment on MainNet."} {"page_id": "smart-contracts-for-eth-devs-.migration", "page_title": "Migration FAQs and Considerations", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 37, "end_char": 303, "estimated_token_count": 40, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThis guide helps Ethereum developers migrate their smart contracts to Polkadot Hub. Most contracts work without modifications on the REVM backend, while the PolkaVM backend offers enhanced performance with minimal adaptation for standard patterns."} {"page_id": "smart-contracts-for-eth-devs-.migration", "page_title": "Migration FAQs and Considerations", "index": 1, "depth": 2, "title": "Migration Considerations", "anchor": "migration-considerations", "start_char": 303, "end_char": 645, "estimated_token_count": 62, "token_estimator": "heuristic-v1", "text": "## Migration Considerations\n\nTake into account the following considerations before migrating your contracts:\n\n- Standard ERC-20, ERC-721, ERC-1155 tokens work without changes.\n- DeFi protocols, DEXs, and AMMs migrate seamlessly.\n- DAOs and governance contracts are fully compatible.\n- Most Solidity contracts deploy identically to Ethereum."} {"page_id": "smart-contracts-for-eth-devs-.migration", "page_title": "Migration FAQs and Considerations", "index": 2, "depth": 2, "title": "Migration Checklist", "anchor": "migration-checklist", "start_char": 645, "end_char": 1058, "estimated_token_count": 81, "token_estimator": "heuristic-v1", "text": "## Migration Checklist\n\nBefore migrating your contracts, review this checklist:\n\n- Factory contracts using PVM bytecode need pre-uploaded dependencies.\n- Contracts using `EXTCODECOPY` for runtime manipulation require review (for projects that will use PVM bytecode, not EVM bytecode).\n- Replace `transfer()` and `send()` with proper reentrancy guards (for projects that will use PVM bytecode, not EVM bytecode)."} @@ -1065,41 +1051,41 @@ {"page_id": "smart-contracts-for-eth-devs-gas-model", "page_title": "Gas Model on the Polkadot Hub", "index": 4, "depth": 2, "title": "Dynamic Gas Pricing", "anchor": "dynamic-gas-pricing", "start_char": 2551, "end_char": 3444, "estimated_token_count": 161, "token_estimator": "heuristic-v1", "text": "## Dynamic Gas Pricing\n\nPallet revive uses dynamic pricing through a \"fee multiplier\" that adjusts based on network congestion:\n\n- When blocks are full, the multiplier increases, making transactions more expensive.\n- When blocks are empty, the multiplier decreases, making transactions cheaper.\n- The multiplier updates after every block based on utilization.\n\nThis creates a market-based pricing mechanism similar to Ethereum's base fee, helping to manage network resources efficiently.\n\nThe gas price returned during estimation is simply the current fee multiplier value.\n\n!!! warning \"Important for Users\"\n Because the fee multiplier can change between when you estimate gas and when your transaction executes, you can add a safety buffer (10-20%) to both your gas limit and gas price. This ensures your transaction will execute successfully even if network conditions change slightly."} {"page_id": "smart-contracts-for-eth-devs-gas-model", "page_title": "Gas Model on the Polkadot Hub", "index": 5, "depth": 2, "title": "Transaction Execution Flow", "anchor": "transaction-execution-flow", "start_char": 3444, "end_char": 4940, "estimated_token_count": 353, "token_estimator": "heuristic-v1", "text": "## Transaction Execution Flow\n\nThe following diagram illustrates the complete lifecycle of a transaction from submission to settlement:\n\n```mermaid\ngraph TD\n U[User/Wallet] --> M[Transaction pool]\n M --> P[Pre-dispatch convert gas to weight and create hold]\n P --> C{Sufficient funds}\n C -->|No| R[Rejected]\n C -->|Yes| X[Execute contract within limits]\n X --> S[Settle fee from actual weight and length; refund]\n S --> B[Included in block]\n```\n\nThe transaction execution flow is as follows:\n\n- **Pool and pre-dispatch**: The transaction enters the pool, `gas` is mapped to `weight`, and a temporary hold is created for the maximum fee exposure. Weight is a two-dimensional tuple (`ref_time`, `proof_size`). Each dimension is tracked independently. The [`WeightToFee`](https://docs.rs/pallet-transaction-payment/latest/pallet_transaction_payment/pallet/trait.Config.html#associatedtype.WeightToFee){target=\\_blank} conversion takes the maximum of the two dimensions (after applying their respective coefficients) to determine the fee.\n- **Funds check**: If the hold is insufficient, the transaction is rejected before any execution.\n- **Execution**: If sufficient, the contract runs within the derived weight limits; a `storage_deposit` may be reserved when new storage is created.\n- **Settlement**: Fees are charged from the actual `weight` used plus the length fee; any unused hold is refunded.\n- **Inclusion**: After settlement, the transaction is included in the block."} {"page_id": "smart-contracts-for-eth-devs-gas-model", "page_title": "Gas Model on the Polkadot Hub", "index": 6, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 4940, "end_char": 5238, "estimated_token_count": 51, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nThe Polkadot Hub's gas model is designed to be Ethereum-compatible while providing the flexibility and efficiency of Polkadot's resource metering system. Developers can build on Ethereum tooling while leveraging Polkadot's advanced features like multi-dimensional resource tracking."} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 17, "end_char": 509, "estimated_token_count": 115, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nPolkadot Hub provides Ethereum compatibility through its JSON-RPC interface, allowing developers to interact with the chain using familiar Ethereum tooling and methods. This document outlines the supported [Ethereum JSON-RPC methods](https://ethereum.org/developers/docs/apis/json-rpc/#json-rpc-methods){target=\\_blank} and provides examples of how to use them.\n\nThis guide uses the Polkadot Hub TestNet endpoint:\n\n```text\nhttps://testnet-passet-hub-eth-rpc.polkadot.io\n```"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 1, "depth": 2, "title": "Available Methods", "anchor": "available-methods", "start_char": 509, "end_char": 531, "estimated_token_count": 4, "token_estimator": "heuristic-v1", "text": "## Available Methods"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 2, "depth": 3, "title": "eth_accounts", "anchor": "eth_accounts", "start_char": 531, "end_char": 962, "estimated_token_count": 146, "token_estimator": "heuristic-v1", "text": "### eth_accounts\n\nReturns a list of addresses owned by the client. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_accounts){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_accounts\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_accounts\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 3, "depth": 3, "title": "eth_blockNumber", "anchor": "eth_blocknumber", "start_char": 962, "end_char": 1401, "estimated_token_count": 145, "token_estimator": "heuristic-v1", "text": "### eth_blockNumber\n\nReturns the number of the most recent block. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_blocknumber){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_blockNumber\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_blockNumber\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 4, "depth": 3, "title": "eth_call", "anchor": "eth_call", "start_char": 1401, "end_char": 3625, "estimated_token_count": 707, "token_estimator": "heuristic-v1", "text": "### eth_call\n\nExecutes a new message call immediately without creating a transaction. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_call){target=\\_blank}.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction call object.\n - **`to` ++\"string\"++**: Recipient address of the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: Hash of the method signature and encoded parameters. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`from` ++\"string\"++**: (Optional) Sender's address for the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (Optional) Gas limit to execute the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit of gas. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Value in wei to send with the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) Block tag or block number to execute the call at. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n\n**Example**:\n\n```bash title=\"eth_call\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_call\",\n \"params\":[{\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"data\": \"INSERT_ENCODED_CALL\"\n }, \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_RECIPIENT_ADDRESS`, `INSERT_ENCODED_CALL`, and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 5, "depth": 3, "title": "eth_chainId", "anchor": "eth_chainid", "start_char": 3625, "end_char": 4055, "estimated_token_count": 145, "token_estimator": "heuristic-v1", "text": "### eth_chainId\n\nReturns the chain ID used for signing transactions. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_chainid){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_chainId\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_chainId\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 6, "depth": 3, "title": "eth_estimateGas", "anchor": "eth_estimategas", "start_char": 4055, "end_char": 6241, "estimated_token_count": 694, "token_estimator": "heuristic-v1", "text": "### eth_estimateGas\n\nEstimates gas required for a transaction. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_estimategas){target=\\_blank}.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction call object.\n - **`to` ++\"string\"++**: Recipient address of the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: Hash of the method signature and encoded parameters. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`from` ++\"string\"++**: (Optional) Sender's address for the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (Optional) Gas limit to execute the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit of gas. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Value in wei to send with the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) Block tag or block number to execute the call at. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n\n**Example**:\n\n```bash title=\"eth_estimateGas\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_estimateGas\",\n \"params\":[{\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"data\": \"INSERT_ENCODED_FUNCTION_CALL\"\n }],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_RECIPIENT_ADDRESS` and `INSERT_ENCODED_CALL` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 7, "depth": 3, "title": "eth_gasPrice", "anchor": "eth_gasprice", "start_char": 6241, "end_char": 6661, "estimated_token_count": 144, "token_estimator": "heuristic-v1", "text": "### eth_gasPrice\n\nReturns the current gas price in Wei. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gasprice){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_gasPrice\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_gasPrice\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 8, "depth": 3, "title": "eth_getBalance", "anchor": "eth_getbalance", "start_char": 6661, "end_char": 7703, "estimated_token_count": 330, "token_estimator": "heuristic-v1", "text": "### eth_getBalance\n\nReturns the balance of a given address. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getbalance){target=\\_blank}.\n\n**Parameters**:\n\n- **`address` ++\"string\"++**: Address to query balance. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n\n**Example**:\n\n```bash title=\"eth_getBalance\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBalance\",\n \"params\":[\"INSERT_ADDRESS\", \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_ADDRESS` and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 9, "depth": 3, "title": "eth_getBlockByHash", "anchor": "eth_getblockbyhash", "start_char": 7703, "end_char": 8598, "estimated_token_count": 266, "token_estimator": "heuristic-v1", "text": "### eth_getBlockByHash\n\nReturns information about a block by its hash. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblockbyhash){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockHash` ++\"string\"++**: The hash of the block to retrieve. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`fullTransactions` ++\"boolean\"++**: If `true`, returns full transaction details; if `false`, returns only transaction hashes.\n\n**Example**:\n\n```bash title=\"eth_getBlockByHash\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBlockByHash\",\n \"params\":[\"INSERT_BLOCK_HASH\", INSERT_BOOLEAN],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_HASH` and `INSERT_BOOLEAN` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 10, "depth": 3, "title": "eth_getBlockByNumber", "anchor": "eth_getblockbynumber", "start_char": 8598, "end_char": 9617, "estimated_token_count": 301, "token_estimator": "heuristic-v1", "text": "### eth_getBlockByNumber\n\nReturns information about a block by its number. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblockbynumber){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`fullTransactions` ++\"boolean\"++**: If `true`, returns full transaction details; if `false`, returns only transaction hashes.\n\n**Example**:\n\n```bash title=\"eth_getBlockByNumber\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBlockByNumber\",\n \"params\":[\"INSERT_BLOCK_VALUE\", INSERT_BOOLEAN],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_VALUE` and `INSERT_BOOLEAN` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 11, "depth": 3, "title": "eth_getBlockTransactionCountByNumber", "anchor": "eth_getblocktransactioncountbynumber", "start_char": 9617, "end_char": 10540, "estimated_token_count": 260, "token_estimator": "heuristic-v1", "text": "### eth_getBlockTransactionCountByNumber\n\nReturns the number of transactions in a block from a block number. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockValue` ++\"string\"++**: The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n\n**Example**:\n\n```bash title=\"eth_getBlockTransactionCountByNumber\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBlockTransactionCountByNumber\",\n \"params\":[\"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 12, "depth": 3, "title": "eth_getBlockTransactionCountByHash", "anchor": "eth_getblocktransactioncountbyhash", "start_char": 10540, "end_char": 11350, "estimated_token_count": 228, "token_estimator": "heuristic-v1", "text": "### eth_getBlockTransactionCountByHash\n\nReturns the number of transactions in a block from a block hash. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockHash` ++\"string\"++**: The hash of the block to retrieve. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getBlockTransactionCountByHash\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBlockTransactionCountByHash\",\n \"params\":[\"INSERT_BLOCK_HASH\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_HASH` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 13, "depth": 3, "title": "eth_getCode", "anchor": "eth_getcode", "start_char": 11350, "end_char": 12378, "estimated_token_count": 327, "token_estimator": "heuristic-v1", "text": "### eth_getCode\n\nReturns the code at a given address. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getcode){target=\\_blank}.\n\n**Parameters**:\n\n- **`address` ++\"string\"++**: Contract or account address to query code. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block).\n\n**Example**:\n\n```bash title=\"eth_getCode\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getCode\",\n \"params\":[\"INSERT_ADDRESS\", \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_ADDRESS` and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 14, "depth": 3, "title": "eth_getLogs", "anchor": "eth_getlogs", "start_char": 12378, "end_char": 14329, "estimated_token_count": 630, "token_estimator": "heuristic-v1", "text": "### eth_getLogs\n\nReturns an array of all logs matching a given filter object. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getlogs){target=\\_blank}.\n\n**Parameters**:\n\n- **`filter` ++\"object\"++**: The filter object.\n - **`fromBlock` ++\"string\"++**: (Optional) Block number or tag to start from. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n - **`toBlock` ++\"string\"++**: (Optional) Block number or tag to end at. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n - **`address` ++\"string\" or \"array of strings\"++**: (Optional) Contract address or a list of addresses from which to get logs. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`topics` ++\"array of strings\"++**: (Optional) Array of topics for filtering logs. Each topic can be a single [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string or an array of such strings (meaning OR).\n - **`blockhash` ++\"string\"++**: (Optional) Hash of a specific block. Cannot be used with `fromBlock` or `toBlock`. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getLogs\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getLogs\",\n \"params\":[{\n \"fromBlock\": \"latest\",\n \"toBlock\": \"latest\"\n }],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 15, "depth": 3, "title": "eth_getStorageAt", "anchor": "eth_getstorageat", "start_char": 14329, "end_char": 15641, "estimated_token_count": 402, "token_estimator": "heuristic-v1", "text": "### eth_getStorageAt\n\nReturns the value from a storage position at a given address. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getstorageat){target=\\_blank}.\n\n**Parameters**:\n\n- **`address` ++\"string\"++**: Contract or account address to query code. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`storageKey` ++\"string\"++**: Position in storage to retrieve data from. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block).\n\n**Example**:\n\n```bash title=\"eth_getStorageAt\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getStorageAt\",\n \"params\":[\"INSERT_ADDRESS\", \"INSERT_STORAGE_KEY\", \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_ADDRESS`, `INSERT_STORAGE_KEY`, and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 16, "depth": 3, "title": "eth_getTransactionCount", "anchor": "eth_gettransactioncount", "start_char": 15641, "end_char": 16728, "estimated_token_count": 329, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionCount\n\nReturns the number of transactions sent from an address (nonce). [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactioncount){target=\\_blank}.\n\n**Parameters**:\n\n- **`address` ++\"string\"++**: Address to query balance. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block).\n\n**Example**:\n\n```bash title=\"eth_getTransactionCount\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionCount\",\n \"params\":[\"INSERT_ADDRESS\", \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_ADDRESS` and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 17, "depth": 3, "title": "eth_getTransactionByHash", "anchor": "eth_gettransactionbyhash", "start_char": 16728, "end_char": 17498, "estimated_token_count": 222, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionByHash\n\nReturns information about a transaction by its hash. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyhash){target=\\_blank}.\n\n**Parameters**:\n\n- **`transactionHash` ++\"string\"++**: The hash of the transaction. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getTransactionByHash\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionByHash\",\n \"params\":[\"INSERT_TRANSACTION_HASH\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_TRANSACTION_HASH` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 18, "depth": 3, "title": "eth_getTransactionByBlockNumberAndIndex", "anchor": "eth_gettransactionbyblocknumberandindex", "start_char": 17498, "end_char": 18704, "estimated_token_count": 330, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionByBlockNumberAndIndex\n\nReturns information about a transaction by block number and transaction index. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyblocknumberandindex){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockValue` ++\"string\"++**: The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`transactionIndex` ++\"string\"++**: The index of the transaction in the block. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getTransactionByBlockNumberAndIndex\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionByBlockNumberAndIndex\",\n \"params\":[\"INSERT_BLOCK_VALUE\", \"INSERT_TRANSACTION_INDEX\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_VALUE` and `INSERT_TRANSACTION_INDEX` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 19, "depth": 3, "title": "eth_getTransactionByBlockHashAndIndex", "anchor": "eth_gettransactionbyblockhashandindex", "start_char": 18704, "end_char": 19785, "estimated_token_count": 296, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionByBlockHashAndIndex\n\nReturns information about a transaction by block hash and transaction index. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyblockhashandindex){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockHash` ++\"string\"++**: The hash of the block. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`transactionIndex` ++\"string\"++**: The index of the transaction in the block. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getTransactionByBlockHashAndIndex\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionByBlockHashAndIndex\",\n \"params\":[\"INSERT_BLOCK_HASH\", \"INSERT_TRANSACTION_INDEX\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_HASH` and `INSERT_TRANSACTION_INDEX` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 20, "depth": 3, "title": "eth_getTransactionReceipt", "anchor": "eth_gettransactionreceipt", "start_char": 19785, "end_char": 20564, "estimated_token_count": 223, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionReceipt\n\nReturns the receipt of a transaction by transaction hash. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionreceipt){target=\\_blank}.\n\n**Parameters**:\n\n- **`transactionHash` ++\"string\"++**: The hash of the transaction. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getTransactionReceipt\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionReceipt\",\n \"params\":[\"INSERT_TRANSACTION_HASH\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_TRANSACTION_HASH` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 21, "depth": 3, "title": "eth_maxPriorityFeePerGas", "anchor": "eth_maxpriorityfeepergas", "start_char": 20564, "end_char": 20979, "estimated_token_count": 125, "token_estimator": "heuristic-v1", "text": "### eth_maxPriorityFeePerGas\n\nReturns an estimate of the current priority fee per gas, in Wei, to be included in a block.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_maxPriorityFeePerGas\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_maxPriorityFeePerGas\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 22, "depth": 3, "title": "eth_sendRawTransaction", "anchor": "eth_sendrawtransaction", "start_char": 20979, "end_char": 21682, "estimated_token_count": 214, "token_estimator": "heuristic-v1", "text": "### eth_sendRawTransaction\n\nSubmits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_sendrawtransaction){target=\\_blank}.\n\n**Parameters**:\n\n- **`callData` ++\"string\"++**: Signed transaction data. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_sendRawTransaction\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_sendRawTransaction\",\n \"params\":[\"INSERT_CALL_DATA\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_CALL_DATA` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 23, "depth": 3, "title": "eth_sendTransaction", "anchor": "eth_sendtransaction", "start_char": 21682, "end_char": 24037, "estimated_token_count": 714, "token_estimator": "heuristic-v1", "text": "### eth_sendTransaction\n\nCreates and sends a new transaction. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_sendtransaction){target=\\_blank}.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction object.\n - **`from` ++\"string\"++**: Address sending the transaction. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`to` ++\"string\"++**: (Optional) Recipient address. No need to provide this value when deploying a contract. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (optional, default: `90000`) gas limit for execution. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Amount of Ether to send. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: (Optional) Contract bytecode or encoded method call. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`nonce` ++\"string\"++**: (Optional) Transaction nonce. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_sendTransaction\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_sendTransaction\",\n \"params\":[{\n \"from\": \"INSERT_SENDER_ADDRESS\",\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"gas\": \"INSERT_GAS_LIMIT\",\n \"gasPrice\": \"INSERT_GAS_PRICE\",\n \"value\": \"INSERT_VALUE\",\n \"input\": \"INSERT_INPUT_DATA\",\n \"nonce\": \"INSERT_NONCE\"\n }],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_SENDER_ADDRESS`, `INSERT_RECIPIENT_ADDRESS`, `INSERT_GAS_LIMIT`, `INSERT_GAS_PRICE`, `INSERT_VALUE`, `INSERT_INPUT_DATA`, and `INSERT_NONCE` with the proper values.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 24, "depth": 3, "title": "eth_syncing", "anchor": "eth_syncing", "start_char": 24037, "end_char": 24478, "estimated_token_count": 150, "token_estimator": "heuristic-v1", "text": "### eth_syncing\n\nReturns an object with syncing data or `false` if not syncing. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_syncing){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_syncing\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_syncing\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 25, "depth": 3, "title": "net_listening", "anchor": "net_listening", "start_char": 24478, "end_char": 24960, "estimated_token_count": 155, "token_estimator": "heuristic-v1", "text": "### net_listening\n\nReturns `true` if the client is currently listening for network connections, otherwise `false`. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#net_listening){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"net_listening\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"net_listening\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 26, "depth": 3, "title": "net_peerCount", "anchor": "net_peercount", "start_char": 24960, "end_char": 25313, "estimated_token_count": 115, "token_estimator": "heuristic-v1", "text": "### net_peerCount\n\nReturns the number of peers currently connected to the client.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"net_peerCount\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"net_peerCount\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 27, "depth": 3, "title": "net_version", "anchor": "net_version", "start_char": 25313, "end_char": 25735, "estimated_token_count": 145, "token_estimator": "heuristic-v1", "text": "### net_version\n\nReturns the current network ID as a string. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#net_version){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"net_version\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"net_version\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 28, "depth": 3, "title": "system_health", "anchor": "system_health", "start_char": 25735, "end_char": 26077, "estimated_token_count": 113, "token_estimator": "heuristic-v1", "text": "### system_health\n\nReturns information about the health of the system.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"system_health\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"system_health\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 29, "depth": 3, "title": "web3_clientVersion", "anchor": "web3_clientversion", "start_char": 26077, "end_char": 26519, "estimated_token_count": 142, "token_estimator": "heuristic-v1", "text": "### web3_clientVersion\n\nReturns the current client version. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#web3_clientversion){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"web3_clientVersion\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"web3_clientVersion\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 30, "depth": 3, "title": "debug_traceBlockByNumber", "anchor": "debug_traceblockbynumber", "start_char": 26519, "end_char": 27595, "estimated_token_count": 324, "token_estimator": "heuristic-v1", "text": "### debug_traceBlockByNumber \n\nTraces a block's execution by its number and returns a detailed execution trace for each transaction.\n\n**Parameters**:\n\n- **`blockValue` ++\"string\"++**: The block number or tag to trace. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`options` ++\"object\"++**: (Optional) An object containing tracer options.\n - **`tracer` ++\"string\"++**: The name of the tracer to use (e.g., `\"callTracer\"`, `\"opTracer\"`).\n - Other tracer-specific options may be supported.\n\n**Example**:\n\n```bash title=\"debug_traceBlockByNumber\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"debug_traceBlockByNumber\",\n \"params\":[\"INSERT_BLOCK_VALUE\", {\"tracer\": \"callTracer\"}],\n \"id\":1\n}'\n```\n\nEnsure to replace `INSERT_BLOCK_VALUE` with a proper block number if needed.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 31, "depth": 3, "title": "debug_traceTransaction", "anchor": "debug_tracetransaction", "start_char": 27595, "end_char": 28439, "estimated_token_count": 249, "token_estimator": "heuristic-v1", "text": "### debug_traceTransaction\n\nTraces the execution of a single transaction by its hash and returns a detailed execution trace.\n\n**Parameters**:\n\n- **`transactionHash` ++\"string\"++**: The hash of the transaction to trace. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`options` ++\"object\"++**: (Optional) An object containing tracer options (e.g., `tracer: \"callTracer\"`).\n\n**Example**:\n\n```bash title=\"debug_traceTransaction\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"debug_traceTransaction\",\n \"params\":[\"INSERT_TRANSACTION_HASH\", {\"tracer\": \"callTracer\"}],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_TRANSACTION_HASH` with the proper value.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 32, "depth": 3, "title": "debug_traceCall", "anchor": "debug_tracecall", "start_char": 28439, "end_char": 30872, "estimated_token_count": 751, "token_estimator": "heuristic-v1", "text": "### debug_traceCall\n\nExecutes a new message call and returns a detailed execution trace without creating a transaction on the blockchain.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction call object, similar to `eth_call` parameters.\n - **`to` ++\"string\"++**: Recipient address of the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: Hash of the method signature and encoded parameters. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`from` ++\"string\"++**: (Optional) Sender's address for the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (Optional) Gas limit to execute the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit of gas. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Value in wei to send with the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) Block tag or block number to execute the call at. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`options` ++\"object\"++**: (Optional) An object containing tracer options (e.g., `tracer: \"callTracer\"`).\n\n**Example**:\n\n```bash title=\"debug_traceCall\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"debug_traceCall\",\n \"params\":[{\n \"from\": \"INSERT_SENDER_ADDRESS\",\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"data\": \"INSERT_ENCODED_CALL\"\n }, \"INSERT_BLOCK_VALUE\", {\"tracer\": \"callTracer\"}],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_SENDER_ADDRESS`, `INSERT_RECIPIENT_ADDRESS`, `INSERT_ENCODED_CALL`, and `INSERT_BLOCK_VALUE` with the proper value.\n\n---"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 33, "depth": 2, "title": "Response Format", "anchor": "response-format", "start_char": 30872, "end_char": 31055, "estimated_token_count": 57, "token_estimator": "heuristic-v1", "text": "## Response Format\n\nAll responses follow the standard JSON-RPC 2.0 format:\n\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"result\": ... // The return value varies by method\n}\n```"} -{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 34, "depth": 2, "title": "Error Handling", "anchor": "error-handling", "start_char": 31055, "end_char": 31274, "estimated_token_count": 64, "token_estimator": "heuristic-v1", "text": "## Error Handling\n\nIf an error occurs, the response will include an error object:\n\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"error\": {\n \"code\": -32000,\n \"message\": \"Error message here\"\n }\n}\n```"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 17, "end_char": 507, "estimated_token_count": 111, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nPolkadot Hub provides Ethereum compatibility through its JSON-RPC interface, allowing developers to interact with the chain using familiar Ethereum tooling and methods. This document outlines the supported [Ethereum JSON-RPC methods](https://ethereum.org/developers/docs/apis/json-rpc/#json-rpc-methods){target=\\_blank} and provides examples of how to use them.\n\nThis guide uses the Polkadot Hub TestNet endpoint:\n\n```text\nhttps://services.polkadothub-rpc.com/testnet\n```"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 1, "depth": 2, "title": "Available Methods", "anchor": "available-methods", "start_char": 507, "end_char": 529, "estimated_token_count": 4, "token_estimator": "heuristic-v1", "text": "## Available Methods"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 2, "depth": 3, "title": "eth_accounts", "anchor": "eth_accounts", "start_char": 529, "end_char": 958, "estimated_token_count": 142, "token_estimator": "heuristic-v1", "text": "### eth_accounts\n\nReturns a list of addresses owned by the client. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_accounts){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_accounts\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_accounts\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 3, "depth": 3, "title": "eth_blockNumber", "anchor": "eth_blocknumber", "start_char": 958, "end_char": 1395, "estimated_token_count": 141, "token_estimator": "heuristic-v1", "text": "### eth_blockNumber\n\nReturns the number of the most recent block. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_blocknumber){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_blockNumber\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_blockNumber\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 4, "depth": 3, "title": "eth_call", "anchor": "eth_call", "start_char": 1395, "end_char": 3617, "estimated_token_count": 703, "token_estimator": "heuristic-v1", "text": "### eth_call\n\nExecutes a new message call immediately without creating a transaction. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_call){target=\\_blank}.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction call object.\n - **`to` ++\"string\"++**: Recipient address of the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: Hash of the method signature and encoded parameters. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`from` ++\"string\"++**: (Optional) Sender's address for the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (Optional) Gas limit to execute the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit of gas. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Value in wei to send with the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) Block tag or block number to execute the call at. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n\n**Example**:\n\n```bash title=\"eth_call\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_call\",\n \"params\":[{\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"data\": \"INSERT_ENCODED_CALL\"\n }, \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_RECIPIENT_ADDRESS`, `INSERT_ENCODED_CALL`, and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 5, "depth": 3, "title": "eth_chainId", "anchor": "eth_chainid", "start_char": 3617, "end_char": 4045, "estimated_token_count": 141, "token_estimator": "heuristic-v1", "text": "### eth_chainId\n\nReturns the chain ID used for signing transactions. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_chainid){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_chainId\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_chainId\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 6, "depth": 3, "title": "eth_estimateGas", "anchor": "eth_estimategas", "start_char": 4045, "end_char": 6229, "estimated_token_count": 690, "token_estimator": "heuristic-v1", "text": "### eth_estimateGas\n\nEstimates gas required for a transaction. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_estimategas){target=\\_blank}.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction call object.\n - **`to` ++\"string\"++**: Recipient address of the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: Hash of the method signature and encoded parameters. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`from` ++\"string\"++**: (Optional) Sender's address for the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (Optional) Gas limit to execute the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit of gas. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Value in wei to send with the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) Block tag or block number to execute the call at. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n\n**Example**:\n\n```bash title=\"eth_estimateGas\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_estimateGas\",\n \"params\":[{\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"data\": \"INSERT_ENCODED_FUNCTION_CALL\"\n }],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_RECIPIENT_ADDRESS` and `INSERT_ENCODED_CALL` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 7, "depth": 3, "title": "eth_gasPrice", "anchor": "eth_gasprice", "start_char": 6229, "end_char": 6647, "estimated_token_count": 140, "token_estimator": "heuristic-v1", "text": "### eth_gasPrice\n\nReturns the current gas price in Wei. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gasprice){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_gasPrice\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_gasPrice\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 8, "depth": 3, "title": "eth_getBalance", "anchor": "eth_getbalance", "start_char": 6647, "end_char": 7687, "estimated_token_count": 326, "token_estimator": "heuristic-v1", "text": "### eth_getBalance\n\nReturns the balance of a given address. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getbalance){target=\\_blank}.\n\n**Parameters**:\n\n- **`address` ++\"string\"++**: Address to query balance. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n\n**Example**:\n\n```bash title=\"eth_getBalance\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBalance\",\n \"params\":[\"INSERT_ADDRESS\", \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_ADDRESS` and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 9, "depth": 3, "title": "eth_getBlockByHash", "anchor": "eth_getblockbyhash", "start_char": 7687, "end_char": 8580, "estimated_token_count": 262, "token_estimator": "heuristic-v1", "text": "### eth_getBlockByHash\n\nReturns information about a block by its hash. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblockbyhash){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockHash` ++\"string\"++**: The hash of the block to retrieve. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`fullTransactions` ++\"boolean\"++**: If `true`, returns full transaction details; if `false`, returns only transaction hashes.\n\n**Example**:\n\n```bash title=\"eth_getBlockByHash\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBlockByHash\",\n \"params\":[\"INSERT_BLOCK_HASH\", INSERT_BOOLEAN],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_HASH` and `INSERT_BOOLEAN` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 10, "depth": 3, "title": "eth_getBlockByNumber", "anchor": "eth_getblockbynumber", "start_char": 8580, "end_char": 9597, "estimated_token_count": 297, "token_estimator": "heuristic-v1", "text": "### eth_getBlockByNumber\n\nReturns information about a block by its number. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblockbynumber){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`fullTransactions` ++\"boolean\"++**: If `true`, returns full transaction details; if `false`, returns only transaction hashes.\n\n**Example**:\n\n```bash title=\"eth_getBlockByNumber\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBlockByNumber\",\n \"params\":[\"INSERT_BLOCK_VALUE\", INSERT_BOOLEAN],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_VALUE` and `INSERT_BOOLEAN` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 11, "depth": 3, "title": "eth_getBlockTransactionCountByNumber", "anchor": "eth_getblocktransactioncountbynumber", "start_char": 9597, "end_char": 10518, "estimated_token_count": 256, "token_estimator": "heuristic-v1", "text": "### eth_getBlockTransactionCountByNumber\n\nReturns the number of transactions in a block from a block number. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockValue` ++\"string\"++**: The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n\n**Example**:\n\n```bash title=\"eth_getBlockTransactionCountByNumber\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBlockTransactionCountByNumber\",\n \"params\":[\"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 12, "depth": 3, "title": "eth_getBlockTransactionCountByHash", "anchor": "eth_getblocktransactioncountbyhash", "start_char": 10518, "end_char": 11326, "estimated_token_count": 224, "token_estimator": "heuristic-v1", "text": "### eth_getBlockTransactionCountByHash\n\nReturns the number of transactions in a block from a block hash. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockHash` ++\"string\"++**: The hash of the block to retrieve. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getBlockTransactionCountByHash\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getBlockTransactionCountByHash\",\n \"params\":[\"INSERT_BLOCK_HASH\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_HASH` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 13, "depth": 3, "title": "eth_getCode", "anchor": "eth_getcode", "start_char": 11326, "end_char": 12352, "estimated_token_count": 323, "token_estimator": "heuristic-v1", "text": "### eth_getCode\n\nReturns the code at a given address. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getcode){target=\\_blank}.\n\n**Parameters**:\n\n- **`address` ++\"string\"++**: Contract or account address to query code. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block).\n\n**Example**:\n\n```bash title=\"eth_getCode\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getCode\",\n \"params\":[\"INSERT_ADDRESS\", \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_ADDRESS` and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 14, "depth": 3, "title": "eth_getLogs", "anchor": "eth_getlogs", "start_char": 12352, "end_char": 14301, "estimated_token_count": 626, "token_estimator": "heuristic-v1", "text": "### eth_getLogs\n\nReturns an array of all logs matching a given filter object. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getlogs){target=\\_blank}.\n\n**Parameters**:\n\n- **`filter` ++\"object\"++**: The filter object.\n - **`fromBlock` ++\"string\"++**: (Optional) Block number or tag to start from. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n - **`toBlock` ++\"string\"++**: (Optional) Block number or tag to end at. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n - **`address` ++\"string\" or \"array of strings\"++**: (Optional) Contract address or a list of addresses from which to get logs. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`topics` ++\"array of strings\"++**: (Optional) Array of topics for filtering logs. Each topic can be a single [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string or an array of such strings (meaning OR).\n - **`blockhash` ++\"string\"++**: (Optional) Hash of a specific block. Cannot be used with `fromBlock` or `toBlock`. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getLogs\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getLogs\",\n \"params\":[{\n \"fromBlock\": \"latest\",\n \"toBlock\": \"latest\"\n }],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 15, "depth": 3, "title": "eth_getStorageAt", "anchor": "eth_getstorageat", "start_char": 14301, "end_char": 15611, "estimated_token_count": 398, "token_estimator": "heuristic-v1", "text": "### eth_getStorageAt\n\nReturns the value from a storage position at a given address. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getstorageat){target=\\_blank}.\n\n**Parameters**:\n\n- **`address` ++\"string\"++**: Contract or account address to query code. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`storageKey` ++\"string\"++**: Position in storage to retrieve data from. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block).\n\n**Example**:\n\n```bash title=\"eth_getStorageAt\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getStorageAt\",\n \"params\":[\"INSERT_ADDRESS\", \"INSERT_STORAGE_KEY\", \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_ADDRESS`, `INSERT_STORAGE_KEY`, and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 16, "depth": 3, "title": "eth_getTransactionCount", "anchor": "eth_gettransactioncount", "start_char": 15611, "end_char": 16696, "estimated_token_count": 325, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionCount\n\nReturns the number of transactions sent from an address (nonce). [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactioncount){target=\\_blank}.\n\n**Parameters**:\n\n- **`address` ++\"string\"++**: Address to query balance. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block).\n\n**Example**:\n\n```bash title=\"eth_getTransactionCount\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionCount\",\n \"params\":[\"INSERT_ADDRESS\", \"INSERT_BLOCK_VALUE\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_ADDRESS` and `INSERT_BLOCK_VALUE` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 17, "depth": 3, "title": "eth_getTransactionByHash", "anchor": "eth_gettransactionbyhash", "start_char": 16696, "end_char": 17464, "estimated_token_count": 218, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionByHash\n\nReturns information about a transaction by its hash. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyhash){target=\\_blank}.\n\n**Parameters**:\n\n- **`transactionHash` ++\"string\"++**: The hash of the transaction. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getTransactionByHash\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionByHash\",\n \"params\":[\"INSERT_TRANSACTION_HASH\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_TRANSACTION_HASH` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 18, "depth": 3, "title": "eth_getTransactionByBlockNumberAndIndex", "anchor": "eth_gettransactionbyblocknumberandindex", "start_char": 17464, "end_char": 18668, "estimated_token_count": 326, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionByBlockNumberAndIndex\n\nReturns information about a transaction by block number and transaction index. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyblocknumberandindex){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockValue` ++\"string\"++**: The block value to be fetched. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`transactionIndex` ++\"string\"++**: The index of the transaction in the block. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getTransactionByBlockNumberAndIndex\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionByBlockNumberAndIndex\",\n \"params\":[\"INSERT_BLOCK_VALUE\", \"INSERT_TRANSACTION_INDEX\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_VALUE` and `INSERT_TRANSACTION_INDEX` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 19, "depth": 3, "title": "eth_getTransactionByBlockHashAndIndex", "anchor": "eth_gettransactionbyblockhashandindex", "start_char": 18668, "end_char": 19747, "estimated_token_count": 292, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionByBlockHashAndIndex\n\nReturns information about a transaction by block hash and transaction index. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyblockhashandindex){target=\\_blank}.\n\n**Parameters**:\n\n- **`blockHash` ++\"string\"++**: The hash of the block. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`transactionIndex` ++\"string\"++**: The index of the transaction in the block. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getTransactionByBlockHashAndIndex\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionByBlockHashAndIndex\",\n \"params\":[\"INSERT_BLOCK_HASH\", \"INSERT_TRANSACTION_INDEX\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_BLOCK_HASH` and `INSERT_TRANSACTION_INDEX` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 20, "depth": 3, "title": "eth_getTransactionReceipt", "anchor": "eth_gettransactionreceipt", "start_char": 19747, "end_char": 20524, "estimated_token_count": 219, "token_estimator": "heuristic-v1", "text": "### eth_getTransactionReceipt\n\nReturns the receipt of a transaction by transaction hash. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionreceipt){target=\\_blank}.\n\n**Parameters**:\n\n- **`transactionHash` ++\"string\"++**: The hash of the transaction. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_getTransactionReceipt\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_getTransactionReceipt\",\n \"params\":[\"INSERT_TRANSACTION_HASH\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_TRANSACTION_HASH` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 21, "depth": 3, "title": "eth_maxPriorityFeePerGas", "anchor": "eth_maxpriorityfeepergas", "start_char": 20524, "end_char": 20937, "estimated_token_count": 121, "token_estimator": "heuristic-v1", "text": "### eth_maxPriorityFeePerGas\n\nReturns an estimate of the current priority fee per gas, in Wei, to be included in a block.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_maxPriorityFeePerGas\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_maxPriorityFeePerGas\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 22, "depth": 3, "title": "eth_sendRawTransaction", "anchor": "eth_sendrawtransaction", "start_char": 20937, "end_char": 21638, "estimated_token_count": 210, "token_estimator": "heuristic-v1", "text": "### eth_sendRawTransaction\n\nSubmits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_sendrawtransaction){target=\\_blank}.\n\n**Parameters**:\n\n- **`callData` ++\"string\"++**: Signed transaction data. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_sendRawTransaction\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_sendRawTransaction\",\n \"params\":[\"INSERT_CALL_DATA\"],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_CALL_DATA` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 23, "depth": 3, "title": "eth_sendTransaction", "anchor": "eth_sendtransaction", "start_char": 21638, "end_char": 23991, "estimated_token_count": 710, "token_estimator": "heuristic-v1", "text": "### eth_sendTransaction\n\nCreates and sends a new transaction. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_sendtransaction){target=\\_blank}.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction object.\n - **`from` ++\"string\"++**: Address sending the transaction. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`to` ++\"string\"++**: (Optional) Recipient address. No need to provide this value when deploying a contract. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (optional, default: `90000`) gas limit for execution. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Amount of Ether to send. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: (Optional) Contract bytecode or encoded method call. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`nonce` ++\"string\"++**: (Optional) Transaction nonce. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n\n**Example**:\n\n```bash title=\"eth_sendTransaction\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_sendTransaction\",\n \"params\":[{\n \"from\": \"INSERT_SENDER_ADDRESS\",\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"gas\": \"INSERT_GAS_LIMIT\",\n \"gasPrice\": \"INSERT_GAS_PRICE\",\n \"value\": \"INSERT_VALUE\",\n \"input\": \"INSERT_INPUT_DATA\",\n \"nonce\": \"INSERT_NONCE\"\n }],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_SENDER_ADDRESS`, `INSERT_RECIPIENT_ADDRESS`, `INSERT_GAS_LIMIT`, `INSERT_GAS_PRICE`, `INSERT_VALUE`, `INSERT_INPUT_DATA`, and `INSERT_NONCE` with the proper values.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 24, "depth": 3, "title": "eth_syncing", "anchor": "eth_syncing", "start_char": 23991, "end_char": 24430, "estimated_token_count": 146, "token_estimator": "heuristic-v1", "text": "### eth_syncing\n\nReturns an object with syncing data or `false` if not syncing. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#eth_syncing){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"eth_syncing\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"eth_syncing\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 25, "depth": 3, "title": "net_listening", "anchor": "net_listening", "start_char": 24430, "end_char": 24910, "estimated_token_count": 151, "token_estimator": "heuristic-v1", "text": "### net_listening\n\nReturns `true` if the client is currently listening for network connections, otherwise `false`. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#net_listening){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"net_listening\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"net_listening\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 26, "depth": 3, "title": "net_peerCount", "anchor": "net_peercount", "start_char": 24910, "end_char": 25261, "estimated_token_count": 111, "token_estimator": "heuristic-v1", "text": "### net_peerCount\n\nReturns the number of peers currently connected to the client.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"net_peerCount\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"net_peerCount\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 27, "depth": 3, "title": "net_version", "anchor": "net_version", "start_char": 25261, "end_char": 25681, "estimated_token_count": 141, "token_estimator": "heuristic-v1", "text": "### net_version\n\nReturns the current network ID as a string. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#net_version){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"net_version\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"net_version\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 28, "depth": 3, "title": "system_health", "anchor": "system_health", "start_char": 25681, "end_char": 26021, "estimated_token_count": 109, "token_estimator": "heuristic-v1", "text": "### system_health\n\nReturns information about the health of the system.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"system_health\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"system_health\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 29, "depth": 3, "title": "web3_clientVersion", "anchor": "web3_clientversion", "start_char": 26021, "end_char": 26461, "estimated_token_count": 138, "token_estimator": "heuristic-v1", "text": "### web3_clientVersion\n\nReturns the current client version. [Reference](https://ethereum.org/developers/docs/apis/json-rpc/#web3_clientversion){target=\\_blank}.\n\n**Parameters**:\n\nNone.\n\n**Example**:\n\n```bash title=\"web3_clientVersion\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"web3_clientVersion\",\n \"params\":[],\n \"id\":1\n}'\n```\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 30, "depth": 3, "title": "debug_traceBlockByNumber", "anchor": "debug_traceblockbynumber", "start_char": 26461, "end_char": 27535, "estimated_token_count": 320, "token_estimator": "heuristic-v1", "text": "### debug_traceBlockByNumber \n\nTraces a block's execution by its number and returns a detailed execution trace for each transaction.\n\n**Parameters**:\n\n- **`blockValue` ++\"string\"++**: The block number or tag to trace. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`options` ++\"object\"++**: (Optional) An object containing tracer options.\n - **`tracer` ++\"string\"++**: The name of the tracer to use (e.g., `\"callTracer\"`, `\"opTracer\"`).\n - Other tracer-specific options may be supported.\n\n**Example**:\n\n```bash title=\"debug_traceBlockByNumber\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"debug_traceBlockByNumber\",\n \"params\":[\"INSERT_BLOCK_VALUE\", {\"tracer\": \"callTracer\"}],\n \"id\":1\n}'\n```\n\nEnsure to replace `INSERT_BLOCK_VALUE` with a proper block number if needed.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 31, "depth": 3, "title": "debug_traceTransaction", "anchor": "debug_tracetransaction", "start_char": 27535, "end_char": 28377, "estimated_token_count": 245, "token_estimator": "heuristic-v1", "text": "### debug_traceTransaction\n\nTraces the execution of a single transaction by its hash and returns a detailed execution trace.\n\n**Parameters**:\n\n- **`transactionHash` ++\"string\"++**: The hash of the transaction to trace. Must be a [32 byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n- **`options` ++\"object\"++**: (Optional) An object containing tracer options (e.g., `tracer: \"callTracer\"`).\n\n**Example**:\n\n```bash title=\"debug_traceTransaction\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"debug_traceTransaction\",\n \"params\":[\"INSERT_TRANSACTION_HASH\", {\"tracer\": \"callTracer\"}],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_TRANSACTION_HASH` with the proper value.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 32, "depth": 3, "title": "debug_traceCall", "anchor": "debug_tracecall", "start_char": 28377, "end_char": 30808, "estimated_token_count": 747, "token_estimator": "heuristic-v1", "text": "### debug_traceCall\n\nExecutes a new message call and returns a detailed execution trace without creating a transaction on the blockchain.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction call object, similar to `eth_call` parameters.\n - **`to` ++\"string\"++**: Recipient address of the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: Hash of the method signature and encoded parameters. Must be a [data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`from` ++\"string\"++**: (Optional) Sender's address for the call. Must be a [20-byte data](https://ethereum.org/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (Optional) Gas limit to execute the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit of gas. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Value in wei to send with the call. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) Block tag or block number to execute the call at. Must be a [quantity](https://ethereum.org/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`options` ++\"object\"++**: (Optional) An object containing tracer options (e.g., `tracer: \"callTracer\"`).\n\n**Example**:\n\n```bash title=\"debug_traceCall\"\ncurl -X POST https://services.polkadothub-rpc.com/testnet \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"debug_traceCall\",\n \"params\":[{\n \"from\": \"INSERT_SENDER_ADDRESS\",\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"data\": \"INSERT_ENCODED_CALL\"\n }, \"INSERT_BLOCK_VALUE\", {\"tracer\": \"callTracer\"}],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_SENDER_ADDRESS`, `INSERT_RECIPIENT_ADDRESS`, `INSERT_ENCODED_CALL`, and `INSERT_BLOCK_VALUE` with the proper value.\n\n---"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 33, "depth": 2, "title": "Response Format", "anchor": "response-format", "start_char": 30808, "end_char": 30991, "estimated_token_count": 57, "token_estimator": "heuristic-v1", "text": "## Response Format\n\nAll responses follow the standard JSON-RPC 2.0 format:\n\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"result\": ... // The return value varies by method\n}\n```"} +{"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 34, "depth": 2, "title": "Error Handling", "anchor": "error-handling", "start_char": 30991, "end_char": 31210, "estimated_token_count": 64, "token_estimator": "heuristic-v1", "text": "## Error Handling\n\nIf an error occurs, the response will include an error object:\n\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"error\": {\n \"code\": -32000,\n \"message\": \"Error message here\"\n }\n}\n```"} {"page_id": "smart-contracts-get-started", "page_title": "Get Started with Smart Contracts", "index": 0, "depth": 2, "title": "Quick Starts", "anchor": "quick-starts", "start_char": 173, "end_char": 1038, "estimated_token_count": 269, "token_estimator": "heuristic-v1", "text": "## Quick Starts\n\nKick off development fast with curated links for connecting, funding, exploring, and deploying your first contract.\n\n| Quick Start | Tools | Description |\n|:---------------------------------------------------:|:---------------------:|:---------------------------------------------------------------:|\n| [Connect to Polkadot](/smart-contracts/connect/) | Polkadot.js, MetaMask | Add the network, configure RPC, verify activity in the explorer |\n| [Get Test Tokens](/smart-contracts/faucet/) | - | Request test funds to deploy and interact with contracts |\n| [Explore Transactions](/smart-contracts/explorers/) | Subscan | Inspect transactions, logs, token transfers, and contract state |"} {"page_id": "smart-contracts-get-started", "page_title": "Get Started with Smart Contracts", "index": 1, "depth": 2, "title": "Build and Test Locally", "anchor": "build-and-test-locally", "start_char": 1038, "end_char": 1913, "estimated_token_count": 276, "token_estimator": "heuristic-v1", "text": "## Build and Test Locally\n\nSet up local environments and CI-friendly workflows to iterate quickly and validate changes before deploying.\n\n| Build and Test Locally | Tools | Description |\n|:-------------------------------------------------------------------------:|:-----------------:|:----------------------------------------------:|\n| [Run a Local Dev Node](/smart-contracts/dev-environments/local-dev-node/) | Polkadot SDK node | Spin up a local node for iterative development |\n| [Use Remix for Development](/smart-contracts/dev-environments/remix/) | Remix | Connect Remix to Polkadot Hub |\n| [Use Hardhat for Development](/smart-contracts/dev-environments/hardhat/) | Hardhat | Project scaffolding and configuration |"} {"page_id": "smart-contracts-get-started", "page_title": "Get Started with Smart Contracts", "index": 2, "depth": 2, "title": "Ethereum Developer Resources", "anchor": "ethereum-developer-resources", "start_char": 1913, "end_char": 3337, "estimated_token_count": 405, "token_estimator": "heuristic-v1", "text": "## Ethereum Developer Resources\n\nBridge your Ethereum knowledge with Polkadot Hub specifics: account mapping, fees, JSON‑RPC, and deployment.\n\n| Ethereum Developer Guides | Description |\n|:-----------------------------------------------------------------------------------------:|:---------------------------------------------------------------:|\n| [Accounts](/smart-contracts/for-eth-devs/accounts/) | How 20‑byte Ethereum addresses map to 32‑byte Polkadot accounts |\n| [Blocks, Transactions, and Fees](/smart-contracts/for-eth-devs/blocks-transactions-fees/) | Transaction types, fees, and multi‑dimensional metering |\n| [Gas Model](/smart-contracts/for-eth-devs/gas-model/) | Gas vs. weight, proof size, and storage deposits |\n| [Contract Deployment](/smart-contracts/for-eth-devs/contract-deployment/) | Deployment patterns and best practices on Polkadot Hub |\n| [JSON‑RPC APIs](/smart-contracts/for-eth-devs/json-rpc-apis/) | Supported Ethereum JSON‑RPC methods and examples |\n| [Dual VM Stack](/smart-contracts/for-eth-devs/dual-vm-stack/) | Overview of EVM and native execution on the Hub |"} @@ -1109,22 +1095,21 @@ {"page_id": "smart-contracts-get-started", "page_title": "Get Started with Smart Contracts", "index": 6, "depth": 2, "title": "Precompiles", "anchor": "precompiles", "start_char": 5922, "end_char": 6972, "estimated_token_count": 299, "token_estimator": "heuristic-v1", "text": "## Precompiles\n\nDiscover precompiled system contracts available on the Hub and how to use them.\n\n| Topic | Description |\n|:--------------------------------------------------------:|:---------------------------------------------------:|\n| [Overview of Precompiles](/smart-contracts/precompiles/) | What precompiles are available on the Hub |\n| [ETH Native](/smart-contracts/precompiles/eth-native/) | EVM precompiles and interfaces |\n| [XCM](/smart-contracts/precompiles/xcm/) | Cross‑chain messaging helpers for contracts |\n\nFrom here, follow the quick starts to get connected, iterate locally with your preferred tools, and use the guides, libraries, integrations, and precompiles as you grow into production‑ready dApps. If you get stuck, [open an issue](https://github.com/polkadot-developers/polkadot-docs/issues/new?template=docs-issue.yml){target=\\_blank} or reach out in the community channels."} {"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 28, "end_char": 495, "estimated_token_count": 75, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nConnecting a compatible wallet is the first essential step for interacting with the Polkadot Hub ecosystem. This guide explores wallet options that support both Substrate and Ethereum compatible layers, enabling transactions and smart contract interactions. Whether you're a developer testing on Polkadot Hub or a user accessing the MainNet, understanding wallet configuration is crucial for accessing the full range of Polkadot Hub's capabilities."} {"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 1, "depth": 2, "title": "Connect Your Wallet", "anchor": "connect-your-wallet", "start_char": 495, "end_char": 519, "estimated_token_count": 5, "token_estimator": "heuristic-v1", "text": "## Connect Your Wallet"} -{"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 2, "depth": 3, "title": "MetaMask", "anchor": "metamask", "start_char": 519, "end_char": 2213, "estimated_token_count": 403, "token_estimator": "heuristic-v1", "text": "### MetaMask\n\n[MetaMask](https://metamask.io/){target=\\_blank} is a popular wallet for interacting with Ethereum-compatible chains. It allows users to connect to test networks that support Ethereum-based smart contracts. However, it's important to emphasize that MetaMask primarily facilitates interactions with smart contracts, giving users access to various chain functionalities. \n\nTo get started with MetaMask, you need to install the [MetaMask extension](https://metamask.io/download/){target=\\_blank} and add it to the browser. Once you install MetaMask, you can set up a new wallet and securely store your seed phrase. This phrase is crucial for recovery in case you lose access.\n\nFor example, to connect to the Polkadot Hub TestNet via MetaMask, you need to follow these steps:\n\n1. Open the MetaMask extension and click on the network icon to switch to the Polkadot Hub TestNet.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-1.webp){: .browser-extension}\n\n2. Click on the **Add a custom network** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-2.webp){: .browser-extension}\n\n3. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\\_blank} section for copy and paste parameters).\n\n ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension}\n\n4. Click on **Polkadot Hub TestNet** to switch the network.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension}\n\nThe steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters."} -{"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 3, "depth": 3, "title": "SubWallet", "anchor": "subwallet", "start_char": 2213, "end_char": 4760, "estimated_token_count": 603, "token_estimator": "heuristic-v1", "text": "### SubWallet\n\n[SubWallet](https://www.subwallet.app/){target=\\_blank} is a popular non-custodial wallet solution for Polkadot and Ethereum ecosystems. It offers seamless integration with Polkadot SDK-based networks while maintaining Ethereum compatibility, making the wallet an ideal choice for users and developers to interact with Polkadot Hub.\n\nSubWallet now fully supports the [Polkadot Hub TestNet](/smart-contracts/connect/){target=\\_blank} where developers can deploy and interact with Ethereum-compatible, Solidity smart contracts.\n\nYou can easily view and manage your Paseo native token (PAS) using the Ethereum RPC endpoint (Passet Hub EVM) or the Substrate node RPC endpoint (passet-hub).\n\n??? code \"Polkadot Hub TestNet\"\n You can see support here for Polkadot Hub's TestNet. The **Passet Hub EVM** network uses an ETH RPC endpoint, and the **passet-hub** uses a Substrate endpoint.\n The ETH RPC endpoint will let you send transactions that follow an ETH format, while the Substrate endpoint will follow a Substrate transaction format.\n Note the PAS token, which is the native token of the Polkadot Hub TestNet.\n\n ![](/images/smart-contracts/integrations/wallets/subwallet-PAS.webp){: .browser-extension}\n\nTo connect to Polkadot Hub TestNet using SubWallet, follow these steps:\n\n1. Install the [SubWallet browser extension](https://chromewebstore.google.com/detail/subwallet-polkadot-wallet/onhogfjeacnfoofkfgppdlbmlmnplgbn?hl=en){target=\\_blank} and set up your wallet by following the on-screen instructions, or refer to our [step-by-step guide](https://docs.subwallet.app/main/extension-user-guide/getting-started/install-subwallet){target=\\_blank} for assistance.\n\n2. After setting up your wallet, click the List icon at the top left corner of the extension window to open **Settings**.\n\n ![](/images/smart-contracts/integrations/wallets/subwallet-01.webp){: .browser-extension}\n\n3. Scroll down and select **Manage networks**.\n\n ![](/images/smart-contracts/integrations/wallets/subwallet-02.webp){: .browser-extension}\n\n4. In the Manage network screen, either scroll down or type in the search bar to find the networks. Once done, enable the toggle next to the network name.\n\n ![](/images/smart-contracts/integrations/wallets/subwallet-03.webp){: .browser-extension}\n\n You are now ready to use SubWallet to interact with [Polkadot Hub TestNet](/smart-contracts/connect/#networks-details){target=\\_blank} seamlessly!\n\n![](/images/smart-contracts/integrations/wallets/subwallet-04.webp){: .browser-extension}"} -{"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 4, "depth": 3, "title": "Talisman", "anchor": "talisman", "start_char": 4760, "end_char": 6507, "estimated_token_count": 431, "token_estimator": "heuristic-v1", "text": "### Talisman\n\n[Talisman](https://talisman.xyz/){target=\\_blank} is a specialized wallet for the Polkadot ecosystem that supports both Substrate and EVM accounts, making it an excellent choice for Polkadot Hub interactions. Talisman offers a more integrated experience for Polkadot-based chains while still providing Ethereum compatibility.\n\nTo use Talisman with Polkadot Hub TestNet:\n\n1. Install the [Talisman extension](https://talisman.xyz/download){target=\\_blank} and set up your wallet by following the on-screen instructions.\n\n2. Once installed, click on the Talisman icon in your browser extensions and click on the **Settings** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-5.webp){: .browser-extension}\n\n3. Click the button **All settings**.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-6.webp){: .browser-extension}\n\n4. Go to the **Networks & Tokens** section.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-7.webp)\n\n5. Click the **Manage networks** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-8.webp)\n\n6. Click the **+ Add network** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-9.webp)\n\n7. Fill in the form with the required parameters and click the **Add network** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-10.webp)\n\n8. After that, you can switch to the Polkadot Hub TestNet by clicking on the network icon and selecting **Polkadot Hub TestNet**.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-11.webp)\n\nAfter selecting the network, Talisman will automatically configure the necessary RPC URL and chain ID for you. You can now use Talisman to interact with the Polkadot Hub TestNet."} -{"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 5, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 6507, "end_char": 7131, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nChoosing the right wallet for Polkadot Hub interactions depends on your specific requirements and familiarity with different interfaces. MetaMask provides a familiar entry point for developers with Ethereum experience, while Talisman offers deeper integration with Polkadot's unique features and native support for both EVM and Substrate accounts. By properly configuring your wallet connection, you gain access to the full spectrum of Polkadot Hub's capabilities.\n\n!!!info\n Remember to always verify network parameters when connecting to ensure a secure and reliable connection to the Polkadot ecosystem."} +{"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 2, "depth": 3, "title": "MetaMask", "anchor": "metamask", "start_char": 519, "end_char": 2344, "estimated_token_count": 443, "token_estimator": "heuristic-v1", "text": "### MetaMask\n\n[MetaMask](https://metamask.io/){target=\\_blank} is a popular wallet for interacting with Ethereum-compatible chains. It allows users to connect to test networks that support Ethereum-based smart contracts. However, it's important to emphasize that MetaMask primarily facilitates interactions with smart contracts, giving users access to various chain functionalities. \n\nTo get started with MetaMask, you need to install the [MetaMask extension](https://metamask.io/download/){target=\\_blank} and add it to the browser. Once you install MetaMask, you can set up a new wallet and securely store your seed phrase. This phrase is crucial for recovery in case you lose access.\n\nFor example, to connect to the Polkadot Hub TestNet via MetaMask, you need to follow these steps:\n\n1. Open the MetaMask extension and click on the network dropdown to switch to the Polkadot Hub TestNet.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-1.webp){: .browser-extension}\n\n2. Click on the **Custom** tab.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-2.webp){: .browser-extension}\n\n3. Click on the **Add a custom network** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension}\n\n4. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\\_blank} section for copy and paste parameters).\n\n ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension}\n\n5. Click on **Polkadot Hub TestNet** to switch the network.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension}\n\nThe steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters."} +{"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 3, "depth": 3, "title": "Talisman", "anchor": "talisman", "start_char": 2344, "end_char": 3793, "estimated_token_count": 352, "token_estimator": "heuristic-v1", "text": "### Talisman\n\n[Talisman](https://talisman.xyz/){target=\\_blank} is a specialized wallet for the Polkadot ecosystem that supports both Substrate and EVM accounts, making it an excellent choice for Polkadot Hub interactions. Talisman offers a more integrated experience for Polkadot-based chains while still providing Ethereum compatibility.\n\nTo use Talisman with Polkadot Hub TestNet:\n\n1. Install the [Talisman extension](https://talisman.xyz/download){target=\\_blank} and set up your wallet by following the on-screen instructions.\n\n2. Once installed, click on the Talisman icon in your browser extensions and click on the **More** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-5.webp){: .browser-extension}\n\n3. Click the button **Manage Networks**.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-6.webp){: .browser-extension}\n\n4. Click on the **+ Add network** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-7.webp)\n\n5. Fill in the form with the required parameters and click the ave** button.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-8.webp)\n\n6. After that, you will see the **Polkadot Hub TestNet** in the list.\n\n ![](/images/smart-contracts/integrations/wallets/wallets-9.webp)\n\nAfter selecting the network, Talisman will automatically configure the necessary RPC URL and chain ID for you. You can now use Talisman to interact with the Polkadot Hub TestNet."} +{"page_id": "smart-contracts-integrations-wallets", "page_title": "Wallets for Polkadot Hub", "index": 4, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 3793, "end_char": 4417, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nChoosing the right wallet for Polkadot Hub interactions depends on your specific requirements and familiarity with different interfaces. MetaMask provides a familiar entry point for developers with Ethereum experience, while Talisman offers deeper integration with Polkadot's unique features and native support for both EVM and Substrate accounts. By properly configuring your wallet connection, you gain access to the full spectrum of Polkadot Hub's capabilities.\n\n!!!info\n Remember to always verify network parameters when connecting to ensure a secure and reliable connection to the Polkadot ecosystem."} {"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 13, "end_char": 539, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[Ethers.js](https://docs.ethers.org/v6/){target=\\_blank} is a lightweight library that enables interaction with Ethereum Virtual Machine (EVM)-compatible blockchains through JavaScript. Ethers is widely used as a toolkit to establish connections and read and write blockchain data. This article demonstrates using Ethers.js to interact and deploy smart contracts to Polkadot Hub.\n\nThis guide is intended for developers who are familiar with JavaScript and want to interact with Polkadot Hub using Ethers.js."} {"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 539, "end_char": 895, "estimated_token_count": 110, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore getting started, ensure you have the following installed:\n\n- **Node.js**: v22.13.1 or later, check the [Node.js installation guide](https://nodejs.org/en/download/current/){target=\\_blank}.\n- **npm**: v6.13.4 or later (comes bundled with Node.js).\n- **Solidity**: This guide uses Solidity `^0.8.9` for smart contract development."} {"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 2, "depth": 2, "title": "Project Structure", "anchor": "project-structure", "start_char": 895, "end_char": 1403, "estimated_token_count": 144, "token_estimator": "heuristic-v1", "text": "## Project Structure\n\nThis project organizes contracts, scripts, and compiled artifacts for easy development and deployment.\n\n```text title=\"Ethers.js Polkadot Hub\"\nethers-project\nβ”œβ”€β”€ contracts\nβ”‚ β”œβ”€β”€ Storage.sol\nβ”œβ”€β”€ scripts\nβ”‚ β”œβ”€β”€ connectToProvider.js\nβ”‚ β”œβ”€β”€ fetchLastBlock.js\nβ”‚ β”œβ”€β”€ compile.js\nβ”‚ β”œβ”€β”€ deploy.js\nβ”‚ β”œβ”€β”€ checkStorage.js\nβ”œβ”€β”€ abis\nβ”‚ β”œβ”€β”€ Storage.json\nβ”œβ”€β”€ artifacts\nβ”‚ β”œβ”€β”€ Storage.bin\nβ”œβ”€β”€ contract-address.json\nβ”œβ”€β”€ node_modules/\nβ”œβ”€β”€ package.json\nβ”œβ”€β”€ package-lock.json\n└── README.md\n```"} {"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 3, "depth": 2, "title": "Set Up the Project", "anchor": "set-up-the-project", "start_char": 1403, "end_char": 1624, "estimated_token_count": 50, "token_estimator": "heuristic-v1", "text": "## Set Up the Project\n\nTo start working with Ethers.js, create a new folder and initialize your project by running the following commands in your terminal:\n\n```bash\nmkdir ethers-project\ncd ethers-project\nnpm init -y\n```"} {"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 4, "depth": 2, "title": "Install Dependencies", "anchor": "install-dependencies", "start_char": 1624, "end_char": 2083, "estimated_token_count": 122, "token_estimator": "heuristic-v1", "text": "## Install Dependencies\n\nNext, run the following command to install the Ethers.js library:\n\n```bash\nnpm install ethers\n```\n\nAdd the Solidity compiler so you can generate standard EVM bytecode:\n\n```bash\nnpm install --save-dev solc\n```\n\nThis guide uses `solc` version `0.8.33`.\n\n!!! tip\n The sample scripts use ECMAScript modules. Add `\"type\": \"module\"` to your `package.json` (or rename the files to `.mjs`) so that `node` can run the `import` statements."} -{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 5, "depth": 2, "title": "Set Up the Ethers.js Provider", "anchor": "set-up-the-ethersjs-provider", "start_char": 2083, "end_char": 4683, "estimated_token_count": 578, "token_estimator": "heuristic-v1", "text": "## Set Up the Ethers.js Provider\n\nA [`Provider`](https://docs.ethers.org/v6/api/providers/#Provider){target=\\_blank} is an abstraction of a connection to the Ethereum network, allowing you to query blockchain data and send transactions. It serves as a bridge between your application and the blockchain.\n\nTo interact with Polkadot Hub, you must set up an Ethers.js provider. This provider connects to a blockchain node, allowing you to query blockchain data and interact with smart contracts. In the root of your project, create a file named `connectToProvider.js` and add the following code:\n\n```js title=\"scripts/connectToProvider.js\"\nconst { JsonRpcProvider } = require('ethers');\n\nconst createProvider = (rpcUrl, chainId, chainName) => {\n const provider = new JsonRpcProvider(rpcUrl, {\n chainId: chainId,\n name: chainName,\n });\n\n return provider;\n};\n\nconst PROVIDER_RPC = {\n rpc: 'INSERT_RPC_URL',\n chainId: 'INSERT_CHAIN_ID',\n name: 'INSERT_CHAIN_NAME',\n};\n\ncreateProvider(PROVIDER_RPC.rpc, PROVIDER_RPC.chainId, PROVIDER_RPC.name);\n\n```\n\n!!! note\n Replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, and `INSERT_CHAIN_NAME` with the appropriate values. For example, to connect to Polkadot Hub TestNet's Ethereum RPC instance, you can use the following parameters:\n\n ```js\n const PROVIDER_RPC = {\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n chainId: 420420422,\n name: 'polkadot-hub-testnet'\n };\n ```\n\nTo connect to the provider, execute:\n\n```bash\nnode scripts/connectToProvider.js\n```\n\nWith the provider set up, you can start querying the blockchain. For instance, to fetch the latest block number:\n\n??? code \"fetchLastBlock.js code\"\n\n ```js title=\"scripts/fetchLastBlock.js\"\n const { JsonRpcProvider } = require('ethers');\n\n const createProvider = (rpcUrl, chainId, chainName) => {\n const provider = new JsonRpcProvider(rpcUrl, {\n chainId: chainId,\n name: chainName,\n });\n\n return provider;\n };\n\n const PROVIDER_RPC = {\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n chainId: 420420422,\n name: 'polkadot-hub-testnet',\n };\n\n const main = async () => {\n try {\n const provider = createProvider(\n PROVIDER_RPC.rpc,\n PROVIDER_RPC.chainId,\n PROVIDER_RPC.name,\n );\n const latestBlock = await provider.getBlockNumber();\n console.log(`Latest block: ${latestBlock}`);\n } catch (error) {\n console.error('Error connecting to Polkadot Hub TestNet: ' + error.message);\n }\n };\n\n main();\n\n ```"} -{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 6, "depth": 2, "title": "Compile Contracts", "anchor": "compile-contracts", "start_char": 4683, "end_char": 5012, "estimated_token_count": 74, "token_estimator": "heuristic-v1", "text": "## Compile Contracts\n\nPolkadot Hub exposes an Ethereum JSON-RPC endpoint, so you can compile Solidity contracts to familiar EVM bytecode with the upstream [`solc`](https://www.npmjs.com/package/solc){target=\\_blank} compiler. The resulting artifacts work with any EVM-compatible toolchain and can be deployed through Ethers.js."} -{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 7, "depth": 3, "title": "Sample Storage Smart Contract", "anchor": "sample-storage-smart-contract", "start_char": 5012, "end_char": 5837, "estimated_token_count": 171, "token_estimator": "heuristic-v1", "text": "### Sample Storage Smart Contract\n\nThis example demonstrates compiling a `Storage.sol` Solidity contract for deployment to Polkadot Hub. The contract's functionality stores a number and permits users to update it with a new value.\n\n```solidity title=\"contracts/Storage.sol\"\n//SPDX-License-Identifier: MIT\n\n// Solidity files have to start with this pragma.\n// It will be used by the Solidity compiler to validate its version.\npragma solidity ^0.8.9;\n\ncontract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n}\n```"} -{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 8, "depth": 3, "title": "Compile the Smart Contract", "anchor": "compile-the-smart-contract", "start_char": 5837, "end_char": 9394, "estimated_token_count": 810, "token_estimator": "heuristic-v1", "text": "### Compile the Smart Contract\n\nTo compile this contract, use the following script:\n\n```js title=\"scripts/compile.js\"\nconst solc = require('solc');\nconst { readFileSync, writeFileSync, mkdirSync, existsSync } = require('fs');\nconst { basename, join } = require('path');\n\nconst ensureDir = (dirPath) => {\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n }\n};\n\nconst compileContract = (solidityFilePath, abiDir, artifactsDir) => {\n try {\n // Read the Solidity file\n const source = readFileSync(solidityFilePath, 'utf8');\n const fileName = basename(solidityFilePath);\n \n // Construct the input object for the Solidity compiler\n const input = {\n language: 'Solidity',\n sources: {\n [fileName]: {\n content: source,\n },\n },\n settings: {\n outputSelection: {\n '*': {\n '*': ['abi', 'evm.bytecode'],\n },\n },\n },\n };\n \n console.log(`Compiling contract: ${fileName}...`);\n \n // Compile the contract\n const output = JSON.parse(solc.compile(JSON.stringify(input)));\n \n // Check for errors\n if (output.errors) {\n const errors = output.errors.filter(error => error.severity === 'error');\n if (errors.length > 0) {\n console.error('Compilation errors:');\n errors.forEach(err => console.error(err.formattedMessage));\n return;\n }\n // Show warnings\n const warnings = output.errors.filter(error => error.severity === 'warning');\n warnings.forEach(warn => console.warn(warn.formattedMessage));\n }\n \n // Ensure output directories exist\n ensureDir(abiDir);\n ensureDir(artifactsDir);\n\n // Process compiled contracts\n for (const [sourceFile, contracts] of Object.entries(output.contracts)) {\n for (const [contractName, contract] of Object.entries(contracts)) {\n console.log(`Compiled contract: ${contractName}`);\n \n // Write the ABI\n const abiPath = join(abiDir, `${contractName}.json`);\n writeFileSync(abiPath, JSON.stringify(contract.abi, null, 2));\n console.log(`ABI saved to ${abiPath}`);\n \n // Write the bytecode\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n writeFileSync(bytecodePath, contract.evm.bytecode.object);\n console.log(`Bytecode saved to ${bytecodePath}`);\n }\n }\n } catch (error) {\n console.error('Error compiling contracts:', error);\n }\n};\n\nconst solidityFilePath = join(__dirname, '../contracts/Storage.sol');\nconst abiDir = join(__dirname, '../abis');\nconst artifactsDir = join(__dirname, '../artifacts');\n\ncompileContract(solidityFilePath, abiDir, artifactsDir);\n```\n\n!!! note \n The script above is tailored to the `Storage.sol` contract. It can be adjusted for other contracts by changing the file name or modifying the ABI and bytecode paths.\n\nThe ABI (Application Binary Interface) is a JSON representation of your contract's functions, events, and their parameters. It serves as the interface between your JavaScript code and the deployed smart contract, allowing your application to know how to format function calls and interpret returned data.\n\nExecute the script above by running:\n\n```bash\nnode scripts/compile.js\n```\n\nAfter executing the script, the Solidity contract is compiled into standard EVM bytecode. The ABI and bytecode are saved into files with `.json` and `.bin` extensions, respectively. You can now proceed with deploying the contract to Polkadot Hub, as outlined in the next section."} -{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 9, "depth": 2, "title": "Deploy the Compiled Contract", "anchor": "deploy-the-compiled-contract", "start_char": 9394, "end_char": 17247, "estimated_token_count": 1672, "token_estimator": "heuristic-v1", "text": "## Deploy the Compiled Contract\n\nTo deploy your compiled contract to Polkadot Hub, you'll need a wallet with a private key to sign the deployment transaction.\n\nYou can create a `deploy.js` script in the root of your project to achieve this. The deployment script can be divided into key components:\n\n1. Set up the required imports and utilities:\n\n ```js title=\"scripts/deploy.js\"\n const { writeFileSync, existsSync, readFileSync } = require('fs');\n const { join } = require('path');\n const { ethers, JsonRpcProvider } = require('ethers');\n\n ```\n\n2. Create a provider to connect to Polkadot Hub:\n\n ```js title=\"scripts/deploy.js\"\n\n // Creates a provider with specified RPC URL and chain details\n const createProvider = (rpcUrl, chainId, chainName) => {\n const provider = new JsonRpcProvider(rpcUrl, {\n chainId: chainId,\n name: chainName,\n });\n return provider;\n };\n ```\n \n3. Set up functions to read contract artifacts:\n\n ```js title=\"scripts/deploy.js\"\n // Reads and parses the ABI file for a given contract\n const getAbi = (contractName) => {\n try {\n const abiPath = join(artifactsDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n // Reads the compiled bytecode for a given contract\n const getByteCode = (contractName) => {\n try {\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n const bytecode = readFileSync(bytecodePath, 'utf8').trim();\n // Add 0x prefix if not present\n return bytecode.startsWith('0x') ? bytecode : `0x${bytecode}`;\n } catch (error) {\n console.error(\n `Could not find bytecode for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n ```\n\n4. Create the main deployment function:\n\n ```js title=\"scripts/deploy.js\"\n const deployContract = async (contractName, mnemonic, providerConfig) => {\n console.log(`Deploying ${contractName}...`);\n try {\n // Step 1: Set up provider and wallet\n const provider = createProvider(\n providerConfig.rpc,\n providerConfig.chainId,\n providerConfig.name,\n );\n const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic);\n const wallet = walletMnemonic.connect(provider);\n\n // Step 2: Create and deploy the contract\n const factory = new ethers.ContractFactory(\n getAbi(contractName),\n getByteCode(contractName),\n wallet,\n );\n const contract = await factory.deploy();\n await contract.waitForDeployment();\n\n // Step 3: Save deployment information\n const address = await contract.getAddress();\n console.log(`Contract ${contractName} deployed at: ${address}`);\n\n const addressesFile = join(scriptsDir, 'contract-address.json');\n const addresses = existsSync(addressesFile)\n ? JSON.parse(readFileSync(addressesFile, 'utf8'))\n : {};\n\n addresses[contractName] = address;\n writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');\n } catch (error) {\n console.error(`Failed to deploy contract ${contractName}:`, error);\n }\n };\n ```\n\n5. Configure and execute the deployment:\n\n ```js title=\"scripts/deploy.js\"\n const providerConfig = {\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready\n chainId: 420420422,\n name: 'polkadot-hub-testnet',\n };\n\n const mnemonic = 'INSERT_MNEMONIC';\n\n deployContract('Storage', mnemonic, providerConfig);\n ```\n\n !!! note\n A mnemonic (seed phrase) is a series of words that can generate multiple private keys and their corresponding addresses. It's used here to derive the wallet that will sign and pay for the deployment transaction. **Always keep your mnemonic secure and never share it publicly**.\n\n Ensure to replace the `INSERT_MNEMONIC` placeholder with your actual mnemonic.\n\n??? code \"View complete script\"\n\n ```js title=\"scripts/deploy.js\"\n const { writeFileSync, existsSync, readFileSync } = require('fs');\n const { join } = require('path');\n const { ethers, JsonRpcProvider } = require('ethers');\n\n const scriptsDir = __dirname;\n const artifactsDir = join(__dirname, '../contracts');\n\n // Creates a provider with specified RPC URL and chain details\n const createProvider = (rpcUrl, chainId, chainName) => {\n const provider = new JsonRpcProvider(rpcUrl, {\n chainId: chainId,\n name: chainName,\n });\n return provider;\n };\n\n // Reads and parses the ABI file for a given contract\n const getAbi = (contractName) => {\n try {\n const abiPath = join(artifactsDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n // Reads the compiled bytecode for a given contract\n const getByteCode = (contractName) => {\n try {\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n const bytecode = readFileSync(bytecodePath, 'utf8').trim();\n // Add 0x prefix if not present\n return bytecode.startsWith('0x') ? bytecode : `0x${bytecode}`;\n } catch (error) {\n console.error(\n `Could not find bytecode for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n const deployContract = async (contractName, mnemonic, providerConfig) => {\n console.log(`Deploying ${contractName}...`);\n try {\n // Step 1: Set up provider and wallet\n const provider = createProvider(\n providerConfig.rpc,\n providerConfig.chainId,\n providerConfig.name,\n );\n const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic);\n const wallet = walletMnemonic.connect(provider);\n\n // Step 2: Create and deploy the contract\n const factory = new ethers.ContractFactory(\n getAbi(contractName),\n getByteCode(contractName),\n wallet,\n );\n const contract = await factory.deploy();\n await contract.waitForDeployment();\n\n // Step 3: Save deployment information\n const address = await contract.getAddress();\n console.log(`Contract ${contractName} deployed at: ${address}`);\n\n const addressesFile = join(scriptsDir, 'contract-address.json');\n const addresses = existsSync(addressesFile)\n ? JSON.parse(readFileSync(addressesFile, 'utf8'))\n : {};\n\n addresses[contractName] = address;\n writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');\n } catch (error) {\n console.error(`Failed to deploy contract ${contractName}:`, error);\n }\n };\n\n const providerConfig = {\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', //TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready\n chainId: 420420422,\n name: 'polkadot-hub-testnet',\n };\n\n const mnemonic = 'INSERT_MNEMONIC';\n\n deployContract('Storage', mnemonic, providerConfig);\n ```\n\nTo run the script, execute the following command:\n\n```bash\nnode scripts/deploy.js\n```\n\nAfter running this script, your contract will be deployed to Polkadot Hub, and its address will be saved in `contract-address.json` within your project directory. You can use this address for future contract interactions."} -{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 10, "depth": 2, "title": "Interact with the Contract", "anchor": "interact-with-the-contract", "start_char": 17247, "end_char": 20687, "estimated_token_count": 751, "token_estimator": "heuristic-v1", "text": "## Interact with the Contract\n\nOnce the contract is deployed, you can interact with it by calling its functions. For example, to set a number, read it and then modify that number by its double, you can create a file named `checkStorage.js` in the root of your project and add the following code:\n\n```js title=\"scripts/checkStorage.js\"\nconst { ethers } = require('ethers');\nconst { readFileSync } = require('fs');\nconst { join } = require('path');\n\nconst artifactsDir = join(__dirname, '../contracts');\n\nconst createProvider = (providerConfig) => {\n return new ethers.JsonRpcProvider(providerConfig.rpc, {\n chainId: providerConfig.chainId,\n name: providerConfig.name,\n });\n};\n\nconst createWallet = (mnemonic, provider) => {\n return ethers.Wallet.fromPhrase(mnemonic).connect(provider);\n};\n\nconst loadContractAbi = (contractName, directory = artifactsDir) => {\n const contractPath = join(directory, `${contractName}.json`);\n const contractJson = JSON.parse(readFileSync(contractPath, 'utf8'));\n return contractJson.abi || contractJson; // Depending on JSON structure\n};\n\nconst createContract = (contractAddress, abi, wallet) => {\n return new ethers.Contract(contractAddress, abi, wallet);\n};\n\nconst interactWithStorageContract = async (\n contractName,\n contractAddress,\n mnemonic,\n providerConfig,\n numberToSet,\n) => {\n try {\n console.log(`Setting new number in Storage contract: ${numberToSet}`);\n\n // Create provider and wallet\n const provider = createProvider(providerConfig);\n const wallet = createWallet(mnemonic, provider);\n\n // Load the contract ABI and create the contract instance\n const abi = loadContractAbi(contractName);\n const contract = createContract(contractAddress, abi, wallet);\n\n // Send a transaction to set the stored number\n const tx1 = await contract.setNumber(numberToSet);\n await tx1.wait(); // Wait for the transaction to be mined\n console.log(`Number successfully set to ${numberToSet}`);\n\n // Retrieve the updated number\n const storedNumber = await contract.storedNumber();\n console.log(`Retrieved stored number:`, storedNumber.toString());\n\n // Send a transaction to set the stored number\n const tx2 = await contract.setNumber(numberToSet * 2);\n await tx2.wait(); // Wait for the transaction to be mined\n console.log(`Number successfully set to ${numberToSet * 2}`);\n\n // Retrieve the updated number\n const updatedNumber = await contract.storedNumber();\n console.log(`Retrieved stored number:`, updatedNumber.toString());\n } catch (error) {\n console.error('Error interacting with Storage contract:', error.message);\n }\n};\n\nconst providerConfig = {\n name: 'asset-hub-smart-contracts',\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n chainId: 420420422,\n};\n\nconst mnemonic = 'INSERT_MNEMONIC'\nconst contractName = 'Storage';\nconst contractAddress = 'INSERT_CONTRACT_ADDRESS'\nconst newNumber = 42;\n\ninteractWithStorageContract(\n contractName,\n contractAddress,\n mnemonic,\n providerConfig,\n newNumber,\n);\n```\n\nEnsure you replace the `INSERT_MNEMONIC` and `INSERT_CONTRACT_ADDRESS` placeholders with actual values. Also, ensure the contract ABI file (`Storage.json`) is correctly referenced. The script prints the balance for `ADDRESS_TO_CHECK` before it writes and doubles the stored value, so pick any account you want to monitor.\n\nTo interact with the contract, run:\n\n```bash\nnode scripts/checkStorage.js\n```"} -{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 11, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 20687, "end_char": 21292, "estimated_token_count": 155, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nNow that you have the foundational knowledge to use Ethers.js with Polkadot Hub, you can:\n\n- **Dive into Ethers.js utilities**: Discover additional Ethers.js features, such as wallet management, signing messages, etc.\n- **Implement batch transactions**: Use Ethers.js to execute batch transactions for efficient multi-step contract interactions.\n- **Build scalable applications**: Combine Ethers.js with frameworks like [`Next.js`](https://nextjs.org/docs){target=\\_blank} or [`Node.js`](https://nodejs.org/en){target=\\_blank} to create full-stack decentralized applications (dApps)."} +{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 5, "depth": 2, "title": "Set Up the Ethers.js Provider", "anchor": "set-up-the-ethersjs-provider", "start_char": 2083, "end_char": 4679, "estimated_token_count": 570, "token_estimator": "heuristic-v1", "text": "## Set Up the Ethers.js Provider\n\nA [`Provider`](https://docs.ethers.org/v6/api/providers/#Provider){target=\\_blank} is an abstraction of a connection to the Ethereum network, allowing you to query blockchain data and send transactions. It serves as a bridge between your application and the blockchain.\n\nTo interact with Polkadot Hub, you must set up an Ethers.js provider. This provider connects to a blockchain node, allowing you to query blockchain data and interact with smart contracts. In the root of your project, create a file named `connectToProvider.js` and add the following code:\n\n```js title=\"scripts/connectToProvider.js\"\nconst { JsonRpcProvider } = require('ethers');\n\nconst createProvider = (rpcUrl, chainId, chainName) => {\n const provider = new JsonRpcProvider(rpcUrl, {\n chainId: chainId,\n name: chainName,\n });\n\n return provider;\n};\n\nconst PROVIDER_RPC = {\n rpc: 'INSERT_RPC_URL',\n chainId: 'INSERT_CHAIN_ID',\n name: 'INSERT_CHAIN_NAME',\n};\n\ncreateProvider(PROVIDER_RPC.rpc, PROVIDER_RPC.chainId, PROVIDER_RPC.name);\n\n```\n\n!!! note\n Replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, and `INSERT_CHAIN_NAME` with the appropriate values. For example, to connect to Polkadot Hub TestNet's Ethereum RPC instance, you can use the following parameters:\n\n ```js\n const PROVIDER_RPC = {\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n name: 'polkadot-hub-testnet'\n };\n ```\n\nTo connect to the provider, execute:\n\n```bash\nnode scripts/connectToProvider.js\n```\n\nWith the provider set up, you can start querying the blockchain. For instance, to fetch the latest block number:\n\n??? code \"fetchLastBlock.js code\"\n\n ```js title=\"scripts/fetchLastBlock.js\"\n const { JsonRpcProvider } = require('ethers');\n\n const createProvider = (rpcUrl, chainId, chainName) => {\n const provider = new JsonRpcProvider(rpcUrl, {\n chainId: chainId,\n name: chainName,\n });\n\n return provider;\n };\n\n const PROVIDER_RPC = {\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n name: 'polkadot-hub-testnet',\n };\n\n const main = async () => {\n try {\n const provider = createProvider(\n PROVIDER_RPC.rpc,\n PROVIDER_RPC.chainId,\n PROVIDER_RPC.name,\n );\n const latestBlock = await provider.getBlockNumber();\n console.log(`Latest block: ${latestBlock}`);\n } catch (error) {\n console.error('Error connecting to Polkadot Hub TestNet: ' + error.message);\n }\n };\n\n main();\n\n ```"} +{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 6, "depth": 2, "title": "Compile Contracts", "anchor": "compile-contracts", "start_char": 4679, "end_char": 5008, "estimated_token_count": 74, "token_estimator": "heuristic-v1", "text": "## Compile Contracts\n\nPolkadot Hub exposes an Ethereum JSON-RPC endpoint, so you can compile Solidity contracts to familiar EVM bytecode with the upstream [`solc`](https://www.npmjs.com/package/solc){target=\\_blank} compiler. The resulting artifacts work with any EVM-compatible toolchain and can be deployed through Ethers.js."} +{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 7, "depth": 3, "title": "Sample Storage Smart Contract", "anchor": "sample-storage-smart-contract", "start_char": 5008, "end_char": 5833, "estimated_token_count": 171, "token_estimator": "heuristic-v1", "text": "### Sample Storage Smart Contract\n\nThis example demonstrates compiling a `Storage.sol` Solidity contract for deployment to Polkadot Hub. The contract's functionality stores a number and permits users to update it with a new value.\n\n```solidity title=\"contracts/Storage.sol\"\n//SPDX-License-Identifier: MIT\n\n// Solidity files have to start with this pragma.\n// It will be used by the Solidity compiler to validate its version.\npragma solidity ^0.8.9;\n\ncontract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n}\n```"} +{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 8, "depth": 3, "title": "Compile the Smart Contract", "anchor": "compile-the-smart-contract", "start_char": 5833, "end_char": 9390, "estimated_token_count": 810, "token_estimator": "heuristic-v1", "text": "### Compile the Smart Contract\n\nTo compile this contract, use the following script:\n\n```js title=\"scripts/compile.js\"\nconst solc = require('solc');\nconst { readFileSync, writeFileSync, mkdirSync, existsSync } = require('fs');\nconst { basename, join } = require('path');\n\nconst ensureDir = (dirPath) => {\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n }\n};\n\nconst compileContract = (solidityFilePath, abiDir, artifactsDir) => {\n try {\n // Read the Solidity file\n const source = readFileSync(solidityFilePath, 'utf8');\n const fileName = basename(solidityFilePath);\n \n // Construct the input object for the Solidity compiler\n const input = {\n language: 'Solidity',\n sources: {\n [fileName]: {\n content: source,\n },\n },\n settings: {\n outputSelection: {\n '*': {\n '*': ['abi', 'evm.bytecode'],\n },\n },\n },\n };\n \n console.log(`Compiling contract: ${fileName}...`);\n \n // Compile the contract\n const output = JSON.parse(solc.compile(JSON.stringify(input)));\n \n // Check for errors\n if (output.errors) {\n const errors = output.errors.filter(error => error.severity === 'error');\n if (errors.length > 0) {\n console.error('Compilation errors:');\n errors.forEach(err => console.error(err.formattedMessage));\n return;\n }\n // Show warnings\n const warnings = output.errors.filter(error => error.severity === 'warning');\n warnings.forEach(warn => console.warn(warn.formattedMessage));\n }\n \n // Ensure output directories exist\n ensureDir(abiDir);\n ensureDir(artifactsDir);\n\n // Process compiled contracts\n for (const [sourceFile, contracts] of Object.entries(output.contracts)) {\n for (const [contractName, contract] of Object.entries(contracts)) {\n console.log(`Compiled contract: ${contractName}`);\n \n // Write the ABI\n const abiPath = join(abiDir, `${contractName}.json`);\n writeFileSync(abiPath, JSON.stringify(contract.abi, null, 2));\n console.log(`ABI saved to ${abiPath}`);\n \n // Write the bytecode\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n writeFileSync(bytecodePath, contract.evm.bytecode.object);\n console.log(`Bytecode saved to ${bytecodePath}`);\n }\n }\n } catch (error) {\n console.error('Error compiling contracts:', error);\n }\n};\n\nconst solidityFilePath = join(__dirname, '../contracts/Storage.sol');\nconst abiDir = join(__dirname, '../abis');\nconst artifactsDir = join(__dirname, '../artifacts');\n\ncompileContract(solidityFilePath, abiDir, artifactsDir);\n```\n\n!!! note \n The script above is tailored to the `Storage.sol` contract. It can be adjusted for other contracts by changing the file name or modifying the ABI and bytecode paths.\n\nThe ABI (Application Binary Interface) is a JSON representation of your contract's functions, events, and their parameters. It serves as the interface between your JavaScript code and the deployed smart contract, allowing your application to know how to format function calls and interpret returned data.\n\nExecute the script above by running:\n\n```bash\nnode scripts/compile.js\n```\n\nAfter executing the script, the Solidity contract is compiled into standard EVM bytecode. The ABI and bytecode are saved into files with `.json` and `.bin` extensions, respectively. You can now proceed with deploying the contract to Polkadot Hub, as outlined in the next section."} +{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 9, "depth": 2, "title": "Deploy the Compiled Contract", "anchor": "deploy-the-compiled-contract", "start_char": 9390, "end_char": 17085, "estimated_token_count": 1618, "token_estimator": "heuristic-v1", "text": "## Deploy the Compiled Contract\n\nTo deploy your compiled contract to Polkadot Hub, you'll need a wallet with a private key to sign the deployment transaction.\n\nYou can create a `deploy.js` script in the root of your project to achieve this. The deployment script can be divided into key components:\n\n1. Set up the required imports and utilities:\n\n ```js title=\"scripts/deploy.js\"\n const { writeFileSync, existsSync, readFileSync } = require('fs');\n const { join } = require('path');\n const { ethers, JsonRpcProvider } = require('ethers');\n\n ```\n\n2. Create a provider to connect to Polkadot Hub:\n\n ```js title=\"scripts/deploy.js\"\n\n // Creates a provider with specified RPC URL and chain details\n const createProvider = (rpcUrl, chainId, chainName) => {\n const provider = new JsonRpcProvider(rpcUrl, {\n chainId: chainId,\n name: chainName,\n });\n return provider;\n };\n ```\n \n3. Set up functions to read contract artifacts:\n\n ```js title=\"scripts/deploy.js\"\n // Reads and parses the ABI file for a given contract\n const getAbi = (contractName) => {\n try {\n const abiPath = join(artifactsDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n // Reads the compiled bytecode for a given contract\n const getByteCode = (contractName) => {\n try {\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n const bytecode = readFileSync(bytecodePath, 'utf8').trim();\n // Add 0x prefix if not present\n return bytecode.startsWith('0x') ? bytecode : `0x${bytecode}`;\n } catch (error) {\n console.error(\n `Could not find bytecode for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n ```\n\n4. Create the main deployment function:\n\n ```js title=\"scripts/deploy.js\"\n const deployContract = async (contractName, mnemonic, providerConfig) => {\n console.log(`Deploying ${contractName}...`);\n try {\n // Step 1: Set up provider and wallet\n const provider = createProvider(\n providerConfig.rpc,\n providerConfig.chainId,\n providerConfig.name,\n );\n const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic);\n const wallet = walletMnemonic.connect(provider);\n\n // Step 2: Create and deploy the contract\n const factory = new ethers.ContractFactory(\n getAbi(contractName),\n getByteCode(contractName),\n wallet,\n );\n const contract = await factory.deploy();\n await contract.waitForDeployment();\n\n // Step 3: Save deployment information\n const address = await contract.getAddress();\n console.log(`Contract ${contractName} deployed at: ${address}`);\n\n const addressesFile = join(scriptsDir, 'contract-address.json');\n const addresses = existsSync(addressesFile)\n ? JSON.parse(readFileSync(addressesFile, 'utf8'))\n : {};\n\n addresses[contractName] = address;\n writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');\n } catch (error) {\n console.error(`Failed to deploy contract ${contractName}:`, error);\n }\n };\n ```\n\n5. Configure and execute the deployment:\n\n ```js title=\"scripts/deploy.js\"\n const providerConfig = {\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n name: 'polkadot-hub-testnet',\n };\n\n const mnemonic = 'INSERT_MNEMONIC';\n\n deployContract('Storage', mnemonic, providerConfig);\n ```\n\n !!! note\n A mnemonic (seed phrase) is a series of words that can generate multiple private keys and their corresponding addresses. It's used here to derive the wallet that will sign and pay for the deployment transaction. **Always keep your mnemonic secure and never share it publicly**.\n\n Ensure to replace the `INSERT_MNEMONIC` placeholder with your actual mnemonic.\n\n??? code \"View complete script\"\n\n ```js title=\"scripts/deploy.js\"\n const { writeFileSync, existsSync, readFileSync } = require('fs');\n const { join } = require('path');\n const { ethers, JsonRpcProvider } = require('ethers');\n\n const scriptsDir = __dirname;\n const artifactsDir = join(__dirname, '../contracts');\n\n // Creates a provider with specified RPC URL and chain details\n const createProvider = (rpcUrl, chainId, chainName) => {\n const provider = new JsonRpcProvider(rpcUrl, {\n chainId: chainId,\n name: chainName,\n });\n return provider;\n };\n\n // Reads and parses the ABI file for a given contract\n const getAbi = (contractName) => {\n try {\n const abiPath = join(artifactsDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n // Reads the compiled bytecode for a given contract\n const getByteCode = (contractName) => {\n try {\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n const bytecode = readFileSync(bytecodePath, 'utf8').trim();\n // Add 0x prefix if not present\n return bytecode.startsWith('0x') ? bytecode : `0x${bytecode}`;\n } catch (error) {\n console.error(\n `Could not find bytecode for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n const deployContract = async (contractName, mnemonic, providerConfig) => {\n console.log(`Deploying ${contractName}...`);\n try {\n // Step 1: Set up provider and wallet\n const provider = createProvider(\n providerConfig.rpc,\n providerConfig.chainId,\n providerConfig.name,\n );\n const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic);\n const wallet = walletMnemonic.connect(provider);\n\n // Step 2: Create and deploy the contract\n const factory = new ethers.ContractFactory(\n getAbi(contractName),\n getByteCode(contractName),\n wallet,\n );\n const contract = await factory.deploy();\n await contract.waitForDeployment();\n\n // Step 3: Save deployment information\n const address = await contract.getAddress();\n console.log(`Contract ${contractName} deployed at: ${address}`);\n\n const addressesFile = join(scriptsDir, 'contract-address.json');\n const addresses = existsSync(addressesFile)\n ? JSON.parse(readFileSync(addressesFile, 'utf8'))\n : {};\n\n addresses[contractName] = address;\n writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');\n } catch (error) {\n console.error(`Failed to deploy contract ${contractName}:`, error);\n }\n };\n\n const providerConfig = {\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n name: 'polkadot-hub-testnet',\n };\n\n const mnemonic = 'INSERT_MNEMONIC';\n\n deployContract('Storage', mnemonic, providerConfig);\n ```\n\nTo run the script, execute the following command:\n\n```bash\nnode scripts/deploy.js\n```\n\nAfter running this script, your contract will be deployed to Polkadot Hub, and its address will be saved in `contract-address.json` within your project directory. You can use this address for future contract interactions."} +{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 10, "depth": 2, "title": "Interact with the Contract", "anchor": "interact-with-the-contract", "start_char": 17085, "end_char": 20510, "estimated_token_count": 743, "token_estimator": "heuristic-v1", "text": "## Interact with the Contract\n\nOnce the contract is deployed, you can interact with it by calling its functions. For example, to set a number, read it and then modify that number by its double, you can create a file named `checkStorage.js` in the root of your project and add the following code:\n\n```js title=\"scripts/checkStorage.js\"\nconst { ethers } = require('ethers');\nconst { readFileSync } = require('fs');\nconst { join } = require('path');\n\nconst artifactsDir = join(__dirname, '../contracts');\n\nconst createProvider = (providerConfig) => {\n return new ethers.JsonRpcProvider(providerConfig.rpc, {\n chainId: providerConfig.chainId,\n name: providerConfig.name,\n });\n};\n\nconst createWallet = (mnemonic, provider) => {\n return ethers.Wallet.fromPhrase(mnemonic).connect(provider);\n};\n\nconst loadContractAbi = (contractName, directory = artifactsDir) => {\n const contractPath = join(directory, `${contractName}.json`);\n const contractJson = JSON.parse(readFileSync(contractPath, 'utf8'));\n return contractJson.abi || contractJson; // Depending on JSON structure\n};\n\nconst createContract = (contractAddress, abi, wallet) => {\n return new ethers.Contract(contractAddress, abi, wallet);\n};\n\nconst interactWithStorageContract = async (\n contractName,\n contractAddress,\n mnemonic,\n providerConfig,\n numberToSet,\n) => {\n try {\n console.log(`Setting new number in Storage contract: ${numberToSet}`);\n\n // Create provider and wallet\n const provider = createProvider(providerConfig);\n const wallet = createWallet(mnemonic, provider);\n\n // Load the contract ABI and create the contract instance\n const abi = loadContractAbi(contractName);\n const contract = createContract(contractAddress, abi, wallet);\n\n // Send a transaction to set the stored number\n const tx1 = await contract.setNumber(numberToSet);\n await tx1.wait(); // Wait for the transaction to be mined\n console.log(`Number successfully set to ${numberToSet}`);\n\n // Retrieve the updated number\n const storedNumber = await contract.storedNumber();\n console.log(`Retrieved stored number:`, storedNumber.toString());\n\n // Send a transaction to set the stored number\n const tx2 = await contract.setNumber(numberToSet * 2);\n await tx2.wait(); // Wait for the transaction to be mined\n console.log(`Number successfully set to ${numberToSet * 2}`);\n\n // Retrieve the updated number\n const updatedNumber = await contract.storedNumber();\n console.log(`Retrieved stored number:`, updatedNumber.toString());\n } catch (error) {\n console.error('Error interacting with Storage contract:', error.message);\n }\n};\n\nconst providerConfig = {\n name: 'polkadot-hub',\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n};\n\nconst mnemonic = 'INSERT_MNEMONIC'\nconst contractName = 'Storage';\nconst contractAddress = 'INSERT_CONTRACT_ADDRESS'\nconst newNumber = 42;\n\ninteractWithStorageContract(\n contractName,\n contractAddress,\n mnemonic,\n providerConfig,\n newNumber,\n);\n```\n\nEnsure you replace the `INSERT_MNEMONIC` and `INSERT_CONTRACT_ADDRESS` placeholders with actual values. Also, ensure the contract ABI file (`Storage.json`) is correctly referenced. The script prints the balance for `ADDRESS_TO_CHECK` before it writes and doubles the stored value, so pick any account you want to monitor.\n\nTo interact with the contract, run:\n\n```bash\nnode scripts/checkStorage.js\n```"} +{"page_id": "smart-contracts-libraries-ethers-js", "page_title": "Deploy Contracts to Polkadot Hub with Ethers.js", "index": 11, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 20510, "end_char": 21115, "estimated_token_count": 155, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nNow that you have the foundational knowledge to use Ethers.js with Polkadot Hub, you can:\n\n- **Dive into Ethers.js utilities**: Discover additional Ethers.js features, such as wallet management, signing messages, etc.\n- **Implement batch transactions**: Use Ethers.js to execute batch transactions for efficient multi-step contract interactions.\n- **Build scalable applications**: Combine Ethers.js with frameworks like [`Next.js`](https://nextjs.org/docs){target=\\_blank} or [`Node.js`](https://nodejs.org/en){target=\\_blank} to create full-stack decentralized applications (dApps)."} {"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 8, "end_char": 285, "estimated_token_count": 56, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[viem](https://viem.sh/){target=\\_blank} is a lightweight TypeScript library designed for interacting with Ethereum-compatible blockchains. This comprehensive guide will walk you through using viem to interact with and deploy smart contracts to Polkadot Hub."} {"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 285, "end_char": 641, "estimated_token_count": 110, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore getting started, ensure you have the following installed:\n\n- **Node.js**: v22.13.1 or later, check the [Node.js installation guide](https://nodejs.org/en/download/current/){target=\\_blank}.\n- **npm**: v6.13.4 or later (comes bundled with Node.js).\n- **Solidity**: This guide uses Solidity `^0.8.9` for smart contract development."} {"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 2, "depth": 2, "title": "Project Structure", "anchor": "project-structure", "start_char": 641, "end_char": 1067, "estimated_token_count": 125, "token_estimator": "heuristic-v1", "text": "## Project Structure\n\nThis project organizes contracts, scripts, and compiled artifacts for easy development and deployment.\n\n```text\nviem-project/\nβ”œβ”€β”€ package.json\nβ”œβ”€β”€ tsconfig.json\nβ”œβ”€β”€ src/\nβ”‚ β”œβ”€β”€ chainConfig.ts\nβ”‚ β”œβ”€β”€ createClient.ts\nβ”‚ β”œβ”€β”€ createWallet.ts\nβ”‚ β”œβ”€β”€ compile.ts\nβ”‚ β”œβ”€β”€ deploy.ts\nβ”‚ └── interact.ts\nβ”œβ”€β”€ contracts/\nβ”‚ └── Storage.sol\nβ”œβ”€β”€ abis/\nβ”‚ └── Storage.json\n└── artifacts/\n └── Storage.bin\n```"} @@ -1132,44 +1117,44 @@ {"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 4, "depth": 2, "title": "Install Dependencies", "anchor": "install-dependencies", "start_char": 1206, "end_char": 1579, "estimated_token_count": 86, "token_estimator": "heuristic-v1", "text": "## Install Dependencies\n\nInstall viem along with other necessary dependencies, including [`solc`](https://www.npmjs.com/package/solc){target=\\_blank}, which enables compiling smart contracts' EVM bytecode.\n\n```bash\n# Install viem and resolc\nnpm install viem solc\n\n# Install TypeScript and development dependencies\nnpm install --save-dev typescript ts-node @types/node\n```"} {"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 5, "depth": 2, "title": "Initialize Project", "anchor": "initialize-project", "start_char": 1579, "end_char": 2089, "estimated_token_count": 137, "token_estimator": "heuristic-v1", "text": "## Initialize Project\n\nInitialize a TypeScript project by running the following command:\n\n```bash\nnpx tsc --init\n```\n\nAdd the following scripts to your `package.json` file to enable running TypeScript files:\n\n```json\n{\n \"scripts\": {\n \"client\": \"ts-node src/createClient.ts\",\n \"compile\": \"ts-node src/compile.ts\",\n \"deploy\": \"ts-node src/deploy.ts\",\n \"interact\": \"ts-node src/interact.ts\"\n },\n}\n```\n\nCreate a directory for your TypeScript source files:\n\n```bash\nmkdir src\n```"} {"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 6, "depth": 2, "title": "Set Up the Chain Configuration", "anchor": "set-up-the-chain-configuration", "start_char": 2089, "end_char": 3044, "estimated_token_count": 205, "token_estimator": "heuristic-v1", "text": "## Set Up the Chain Configuration\n\nThe first step is to set up the chain configuration. Create a new file at `src/chainConfig.ts`:\n\n```typescript title=\"src/chainConfig.ts\"\nimport { http } from 'viem';\n\nexport const TRANSPORT = http('INSERT_RPC_URL');\n\n// Configure the Polkadot Hub chain\nexport const POLKADOT_HUB = {\n id: INSERT_CHAIN_ID,\n name: 'INSERT_CHAIN_NAME',\n network: 'INSERT_NETWORK_NAME',\n nativeCurrency: {\n decimals: INSERT_CHAIN_DECIMALS,\n name: 'INSERT_CURRENCY_NAME',\n symbol: 'INSERT_CURRENCY_SYMBOL',\n },\n rpcUrls: {\n default: {\n http: ['INSERT_RPC_URL'],\n },\n },\n} as const;\n```\n\nEnsure to replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, `INSERT_CHAIN_NAME`, `INSERT_NETWORK_NAME`, `INSERT_CHAIN_DECIMALS`, `INSERT_CURRENCY_NAME`, and `INSERT_CURRENCY_SYMBOL` with the proper values. Check the [Connect to Polkadot](/smart-contracts/connect/){target=\\_blank} page for more information on the possible values."} -{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 7, "depth": 2, "title": "Set Up the viem Client", "anchor": "set-up-the-viem-client", "start_char": 3044, "end_char": 5252, "estimated_token_count": 505, "token_estimator": "heuristic-v1", "text": "## Set Up the viem Client\n\nTo interact with the chain, you need to create a client that is used solely for reading data. To accomplish this, create a new file at `src/createClient.ts`:\n\n```typescript title=\"src/createClient.ts\"\nimport { createPublicClient, createWalletClient, http } from 'viem';\n\nconst transport = http('INSERT_RPC_URL');\n\n// Configure the Polkadot Hub chain\nconst assetHub = {\n id: INSERT_CHAIN_ID,\n name: 'INSERT_CHAIN_NAME',\n network: 'INSERT_NETWORK_NAME',\n nativeCurrency: {\n decimals: INSERT_CHAIN_DECIMALS,\n name: 'INSERT_CURRENCY_NAME',\n symbol: 'INSERT_CURRENCY_SYMBOL',\n },\n rpcUrls: {\n default: {\n http: ['INSERT_RPC_URL'],\n },\n },\n} as const;\n\n// Create a public client for reading data\nexport const publicClient = createPublicClient({\n chain: assetHub,\n transport,\n});\n\n```\n\nAfter setting up the [Public Client](https://viem.sh/docs/clients/public#public-client){target=\\_blank}, you can begin querying the blockchain. Here's an example of fetching the latest block number:\n\n??? code \"Fetch Last Block code\"\n\n ```js title=\"src/fetchLastBlock.ts\"\n import { createPublicClient, http } from 'viem';\n\n const transport = http('https://testnet-passet-hub-eth-rpc.polkadot.io'); // TODO: change to paseo asset hub once ready\n\n // Configure the Polkadot Hub chain\n const polkadotHubTestnet = {\n id: 420420422,\n name: 'Polkadot Hub TestNet',\n network: 'polkadot-hub-testnet',\n nativeCurrency: {\n decimals: 18,\n name: 'PAS',\n symbol: 'PAS',\n },\n rpcUrls: {\n default: {\n http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready\n },\n },\n } as const;\n\n // Create a public client for reading data\n export const publicClient = createPublicClient({\n chain: polkadotHubTestnet,\n transport,\n });\n\n const main = async () => {\n try {\n const block = await publicClient.getBlock();\n console.log('Last block: ' + block.number.toString());\n } catch (error: unknown) {\n console.error('Error connecting to Polkadot Hub TestNet: ' + error);\n }\n };\n\n main();\n ```"} -{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 8, "depth": 2, "title": "Set Up a Wallet", "anchor": "set-up-a-wallet", "start_char": 5252, "end_char": 6609, "estimated_token_count": 299, "token_estimator": "heuristic-v1", "text": "## Set Up a Wallet\n\nIn case you need to sign transactions, you will need to instantiate a [Wallet Client](https://viem.sh/docs/clients/wallet#wallet-client){target=\\_blank} object within your project. To do so, create `src/createWallet.ts`:\n\n```typescript title=\"src/createWallet.ts\"\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { createWalletClient, http } from 'viem';\n\nconst transport = http('INSERT_RPC_URL');\n\n// Configure the Polkadot Hub chain\nconst assetHub = {\n id: INSERT_CHAIN_ID,\n name: 'INSERT_CHAIN_NAME',\n network: 'INSERT_NETWORK_NAME',\n nativeCurrency: {\n decimals: INSERT_CHAIN_DECIMALS,\n name: 'INSERT_CURRENCY_NAME',\n symbol: 'INSERT_CURRENCY_SYMBOL',\n },\n rpcUrls: {\n default: {\n http: ['INSERT_RPC_URL'],\n },\n public: {\n http: ['INSERT_RPC_URL'],\n },\n },\n} as const;\n\n// Create a wallet client for writing data\nexport const createWallet = (privateKey: `0x${string}`) => {\n const account = privateKeyToAccount(privateKey);\n return createWalletClient({\n account,\n chain: assetHub,\n transport,\n });\n};\n```\n\n!!!note\n The wallet you import with your private key must have sufficient funds to pay for transaction fees when deploying contracts or interacting with them. Make sure to fund your wallet with the appropriate native tokens for the network you're connecting to."} -{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 9, "depth": 2, "title": "Sample Smart Contract", "anchor": "sample-smart-contract", "start_char": 6609, "end_char": 7590, "estimated_token_count": 204, "token_estimator": "heuristic-v1", "text": "## Sample Smart Contract\n\nThis example demonstrates compiling a `Storage.sol` Solidity contract for deployment to Polkadot Hub. The contract's functionality stores a number and permits users to update it with a new value.\n\n```bash\nmkdir contracts artifacts\n```\n\nYou can use the following contract to interact with the blockchain. Paste the following contract in `contracts/Storage.sol`:\n\n```solidity title=\"contracts/Storage.sol\"\n//SPDX-License-Identifier: MIT\n\n// Solidity files have to start with this pragma.\n// It will be used by the Solidity compiler to validate its version.\npragma solidity ^0.8.9;\n\ncontract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n}\n```"} -{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 10, "depth": 2, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 7590, "end_char": 10649, "estimated_token_count": 723, "token_estimator": "heuristic-v1", "text": "## Compile the Contract\n\nCreate a new file at `src/compile.ts` for handling contract compilation:\n\n```typescript title=\"src/compile.ts\"\nimport solc from 'solc';\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';\nimport { basename, join } from 'path';\n\nconst ensureDir = (dirPath: string): void => {\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n }\n};\n\nconst compileContract = (\n solidityFilePath: string,\n abiDir: string,\n artifactsDir: string\n): void => {\n try {\n // Read the Solidity file\n const source: string = readFileSync(solidityFilePath, 'utf8');\n const fileName: string = basename(solidityFilePath);\n \n // Construct the input object for the Solidity compiler\n const input = {\n language: 'Solidity',\n sources: {\n [fileName]: {\n content: source,\n },\n },\n settings: {\n outputSelection: {\n '*': {\n '*': ['abi', 'evm.bytecode'],\n },\n },\n },\n };\n \n console.log(`Compiling contract: ${fileName}...`);\n \n // Compile the contract\n const output = JSON.parse(solc.compile(JSON.stringify(input)));\n \n // Check for errors\n if (output.errors) {\n const errors = output.errors.filter((error: any) => error.severity === 'error');\n if (errors.length > 0) {\n console.error('Compilation errors:');\n errors.forEach((err: any) => console.error(err.formattedMessage));\n return;\n }\n // Show warnings\n const warnings = output.errors.filter((error: any) => error.severity === 'warning');\n warnings.forEach((warn: any) => console.warn(warn.formattedMessage));\n }\n \n // Ensure output directories exist\n ensureDir(abiDir);\n ensureDir(artifactsDir);\n \n // Process compiled contracts\n for (const [sourceFile, contracts] of Object.entries(output.contracts)) {\n for (const [contractName, contract] of Object.entries(contracts as any)) {\n console.log(`Compiled contract: ${contractName}`);\n \n // Write the ABI\n const abiPath = join(abiDir, `${contractName}.json`);\n writeFileSync(abiPath, JSON.stringify((contract as any).abi, null, 2));\n console.log(`ABI saved to ${abiPath}`);\n \n // Write the bytecode\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n writeFileSync(bytecodePath, (contract as any).evm.bytecode.object);\n console.log(`Bytecode saved to ${bytecodePath}`);\n }\n }\n } catch (error) {\n console.error('Error compiling contracts:', error);\n }\n};\n\nconst solidityFilePath: string = './contracts/Storage.sol';\nconst abiDir: string = './abis';\nconst artifactsDir: string = './artifacts';\n\ncompileContract(solidityFilePath, abiDir, artifactsDir);\n```\n\nTo compile your contract:\n\n```bash\nnpm run compile\n```\n\nAfter executing this script, you will see the compilation results including the generated `Storage.json` (containing the contract's ABI) and `Storage.bin` (containing the compiled bytecode)."} -{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 11, "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 10649, "end_char": 13274, "estimated_token_count": 610, "token_estimator": "heuristic-v1", "text": "## Deploy the Contract\n\nCreate a new file at `src/deploy.ts` for handling contract deployment:\n\n```typescript title=\"src/deploy.ts\"\nimport { existsSync, readFileSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { createWallet } from './createWallet.ts';\nimport { publicClient } from './createClient.ts';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst ABIS_DIR = join(__dirname, '../abis');\nconst ARTIFACTS_DIR = join(__dirname, '../artifacts');\n\nconst deployContract = async (\n contractName: string,\n privateKey: `0x${string}`\n) => {\n try {\n console.log(`Deploying ${contractName}...`);\n\n const abiPath = join(ABIS_DIR, `${contractName}.json`);\n const bytecodePath = join(ARTIFACTS_DIR, `${contractName}.bin`);\n\n if (!existsSync(abiPath) || !existsSync(bytecodePath)) {\n throw new Error(\n `Missing artifacts for ${contractName}. Try running \"npm run compile\" first.`\n );\n }\n\n // Read contract artifacts\n const abi = JSON.parse(\n readFileSync(abiPath, 'utf8')\n );\n const bytecode = `0x${readFileSync(bytecodePath, 'utf8').trim()}` as `0x${string}`;\n\n // Create wallet\n const wallet = createWallet(privateKey);\n\n // Deploy contract\n const hash = await wallet.deployContract({\n abi,\n bytecode,\n args: [], // Add constructor arguments if needed\n });\n\n // Wait for deployment\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const contractAddress = receipt.contractAddress;\n\n console.log(`Contract deployed at: ${contractAddress}`);\n return contractAddress;\n } catch (error) {\n console.error('Deployment failed:', error);\n throw error;\n }\n};\n\nconst privateKey = 'INSERT_PRIVATE_KEY';\ndeployContract('Storage', privateKey);\n```\n\nEnsure to replace `INSERT_PRIVATE_KEY` with the proper value. For further details on private key exportation, refer to the article [How to export an account's private key](https://support.metamask.io/configure/accounts/how-to-export-an-accounts-private-key/){target=\\_blank}.\n\n!!! warning\n Never commit or share your private key. Exposed keys can lead to immediate theft of all associated funds. Use environment variables instead.\n\nTo deploy, run the following command:\n\n```bash\nnpm run deploy\n```\n\nIf everything is successful, you will see the address of your deployed contract displayed in the terminal. This address is unique to your contract on the network you defined in the chain configuration, and you'll need it for any future interactions with your contract."} -{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 12, "depth": 2, "title": "Interact with the Contract", "anchor": "interact-with-the-contract", "start_char": 13274, "end_char": 15647, "estimated_token_count": 510, "token_estimator": "heuristic-v1", "text": "## Interact with the Contract\n\nCreate a new file at `src/interact.ts` for interacting with your deployed contract:\n\n```typescript title=\"src/interact.ts\"\nimport { readFileSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { publicClient } from './createClient.ts';\nimport { createWallet } from './createWallet.ts';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst ABI_PATH = join(__dirname, '../abis/Storage.json');\n\nconst STORAGE_ABI = JSON.parse(readFileSync(ABI_PATH, 'utf8'));\n\nconst interactWithStorage = async (\n contractAddress: `0x${string}`,\n privateKey: `0x${string}`\n) => {\n try {\n const wallet = createWallet(privateKey);\n const currentNumber = await publicClient.readContract({\n address: contractAddress,\n abi: STORAGE_ABI,\n functionName: 'storedNumber',\n args: [],\n });\n console.log(`Stored number: ${currentNumber}`);\n\n const newNumber = BigInt(42);\n const { request } = await publicClient.simulateContract({\n address: contractAddress,\n abi: STORAGE_ABI,\n functionName: 'setNumber',\n args: [newNumber],\n account: wallet.account,\n });\n\n const hash = await wallet.writeContract(request);\n await publicClient.waitForTransactionReceipt({ hash });\n console.log(`Number updated to ${newNumber}`);\n\n const updatedNumber = await publicClient.readContract({\n address: contractAddress,\n abi: STORAGE_ABI,\n functionName: 'storedNumber',\n args: [],\n });\n console.log('Updated stored number:', updatedNumber);\n } catch (error) {\n console.error('Interaction failed:', error);\n }\n};\n\nconst PRIVATE_KEY = 'INSERT_PRIVATE_KEY';\nconst CONTRACT_ADDRESS = 'INSERT_CONTRACT_ADDRESS';\n\ninteractWithStorage(CONTRACT_ADDRESS, PRIVATE_KEY);\n```\n\nEnsure to replace `INSERT_PRIVATE_KEY` and `INSERT_CONTRACT_ADDRESS` with the proper values.\n\nTo interact with the contract:\n\n```bash\nnpm run interact\n```\n\nFollowing a successful interaction, you will see the stored value before and after the transaction. The output will show the initial stored number (0 if you haven't modified it yet), confirm when the transaction to set the number to 42 is complete, and then display the updated stored number value. This demonstrates both reading from and writing to your smart contract."} -{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 13, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 15647, "end_char": 17416, "estimated_token_count": 545, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nNow that you have the foundation for using viem with Polkadot Hub, consider exploring:\n\n
\n\n- External __Advanced viem Features__\n\n ---\n Explore viem's documentation:\n
    \n
  • [:octicons-arrow-right-24: Multi call](https://viem.sh/docs/contract/multicall#multicall){target=\\_blank}
  • \n\n
  • [:octicons-arrow-right-24: Batch transactions](https://viem.sh/docs/clients/transports/http#batch-json-rpc){target=\\_blank}
  • \n\n
  • [:octicons-arrow-right-24: Custom actions](https://viem.sh/docs/clients/custom#extending-with-actions-or-configuration){target=\\_blank}
  • \n
\n\n- External __Test Frameworks__\n\n ---\n\n Integrate viem with the following frameworks for comprehensive testing:\n
    \n
  • [:octicons-arrow-right-24: Hardhat](https://hardhat.org/){target=\\_blank}
  • \n\n
  • [:octicons-arrow-right-24: Foundry](https://getfoundry.sh/){target=\\_blank}
  • \n
\n\n- External __Event Handling__\n\n ---\n\n Learn how to subscribe to and process contract events:\n
    \n
  • [:octicons-arrow-right-24: Event subscription](https://viem.sh/docs/actions/public/watchEvent#watchevent){target=\\_blank}
  • \n
\n\n- External __Building dApps__\n\n ---\n\n Combine viem the following technologies to create full-stack applications:\n
    \n
  • [:octicons-arrow-right-24: Next.js](https://nextjs.org/docs){target=\\_blank}
  • \n\n
  • [:octicons-arrow-right-24: Node.js](https://nodejs.org/en){target=\\_blank}
  • \n
\n\n
"} +{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 7, "depth": 2, "title": "Set Up the viem Client", "anchor": "set-up-the-viem-client", "start_char": 3044, "end_char": 5156, "estimated_token_count": 475, "token_estimator": "heuristic-v1", "text": "## Set Up the viem Client\n\nTo interact with the chain, you need to create a client that is used solely for reading data. To accomplish this, create a new file at `src/createClient.ts`:\n\n```typescript title=\"src/createClient.ts\"\nimport { createPublicClient, createWalletClient, http } from 'viem';\n\nconst transport = http('INSERT_RPC_URL');\n\n// Configure the Polkadot Hub chain\nconst assetHub = {\n id: INSERT_CHAIN_ID,\n name: 'INSERT_CHAIN_NAME',\n network: 'INSERT_NETWORK_NAME',\n nativeCurrency: {\n decimals: INSERT_CHAIN_DECIMALS,\n name: 'INSERT_CURRENCY_NAME',\n symbol: 'INSERT_CURRENCY_SYMBOL',\n },\n rpcUrls: {\n default: {\n http: ['INSERT_RPC_URL'],\n },\n },\n} as const;\n\n// Create a public client for reading data\nexport const publicClient = createPublicClient({\n chain: assetHub,\n transport,\n});\n\n```\n\nAfter setting up the [Public Client](https://viem.sh/docs/clients/public#public-client){target=\\_blank}, you can begin querying the blockchain. Here's an example of fetching the latest block number:\n\n??? code \"Fetch Last Block code\"\n\n ```js title=\"src/fetchLastBlock.ts\"\n import { createPublicClient, http } from 'viem';\n\n const transport = http('https://services.polkadothub-rpc.com/testnet');\n\n // Configure the Polkadot Hub chain\n const polkadotHubTestnet = {\n id: 420420417,\n name: 'Polkadot Hub TestNet',\n network: 'polkadot-hub-testnet',\n nativeCurrency: {\n decimals: 18,\n name: 'PAS',\n symbol: 'PAS',\n },\n rpcUrls: {\n default: {\n http: ['https://services.polkadothub-rpc.com/testnet'],\n },\n },\n } as const;\n\n // Create a public client for reading data\n export const publicClient = createPublicClient({\n chain: polkadotHubTestnet,\n transport,\n });\n\n const main = async () => {\n try {\n const block = await publicClient.getBlock();\n console.log('Last block: ' + block.number.toString());\n } catch (error: unknown) {\n console.error('Error connecting to Polkadot Hub TestNet: ' + error);\n }\n };\n\n main();\n ```"} +{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 8, "depth": 2, "title": "Set Up a Wallet", "anchor": "set-up-a-wallet", "start_char": 5156, "end_char": 6513, "estimated_token_count": 299, "token_estimator": "heuristic-v1", "text": "## Set Up a Wallet\n\nIn case you need to sign transactions, you will need to instantiate a [Wallet Client](https://viem.sh/docs/clients/wallet#wallet-client){target=\\_blank} object within your project. To do so, create `src/createWallet.ts`:\n\n```typescript title=\"src/createWallet.ts\"\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { createWalletClient, http } from 'viem';\n\nconst transport = http('INSERT_RPC_URL');\n\n// Configure the Polkadot Hub chain\nconst assetHub = {\n id: INSERT_CHAIN_ID,\n name: 'INSERT_CHAIN_NAME',\n network: 'INSERT_NETWORK_NAME',\n nativeCurrency: {\n decimals: INSERT_CHAIN_DECIMALS,\n name: 'INSERT_CURRENCY_NAME',\n symbol: 'INSERT_CURRENCY_SYMBOL',\n },\n rpcUrls: {\n default: {\n http: ['INSERT_RPC_URL'],\n },\n public: {\n http: ['INSERT_RPC_URL'],\n },\n },\n} as const;\n\n// Create a wallet client for writing data\nexport const createWallet = (privateKey: `0x${string}`) => {\n const account = privateKeyToAccount(privateKey);\n return createWalletClient({\n account,\n chain: assetHub,\n transport,\n });\n};\n```\n\n!!!note\n The wallet you import with your private key must have sufficient funds to pay for transaction fees when deploying contracts or interacting with them. Make sure to fund your wallet with the appropriate native tokens for the network you're connecting to."} +{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 9, "depth": 2, "title": "Sample Smart Contract", "anchor": "sample-smart-contract", "start_char": 6513, "end_char": 7494, "estimated_token_count": 204, "token_estimator": "heuristic-v1", "text": "## Sample Smart Contract\n\nThis example demonstrates compiling a `Storage.sol` Solidity contract for deployment to Polkadot Hub. The contract's functionality stores a number and permits users to update it with a new value.\n\n```bash\nmkdir contracts artifacts\n```\n\nYou can use the following contract to interact with the blockchain. Paste the following contract in `contracts/Storage.sol`:\n\n```solidity title=\"contracts/Storage.sol\"\n//SPDX-License-Identifier: MIT\n\n// Solidity files have to start with this pragma.\n// It will be used by the Solidity compiler to validate its version.\npragma solidity ^0.8.9;\n\ncontract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n}\n```"} +{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 10, "depth": 2, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 7494, "end_char": 10553, "estimated_token_count": 723, "token_estimator": "heuristic-v1", "text": "## Compile the Contract\n\nCreate a new file at `src/compile.ts` for handling contract compilation:\n\n```typescript title=\"src/compile.ts\"\nimport solc from 'solc';\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';\nimport { basename, join } from 'path';\n\nconst ensureDir = (dirPath: string): void => {\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n }\n};\n\nconst compileContract = (\n solidityFilePath: string,\n abiDir: string,\n artifactsDir: string\n): void => {\n try {\n // Read the Solidity file\n const source: string = readFileSync(solidityFilePath, 'utf8');\n const fileName: string = basename(solidityFilePath);\n \n // Construct the input object for the Solidity compiler\n const input = {\n language: 'Solidity',\n sources: {\n [fileName]: {\n content: source,\n },\n },\n settings: {\n outputSelection: {\n '*': {\n '*': ['abi', 'evm.bytecode'],\n },\n },\n },\n };\n \n console.log(`Compiling contract: ${fileName}...`);\n \n // Compile the contract\n const output = JSON.parse(solc.compile(JSON.stringify(input)));\n \n // Check for errors\n if (output.errors) {\n const errors = output.errors.filter((error: any) => error.severity === 'error');\n if (errors.length > 0) {\n console.error('Compilation errors:');\n errors.forEach((err: any) => console.error(err.formattedMessage));\n return;\n }\n // Show warnings\n const warnings = output.errors.filter((error: any) => error.severity === 'warning');\n warnings.forEach((warn: any) => console.warn(warn.formattedMessage));\n }\n \n // Ensure output directories exist\n ensureDir(abiDir);\n ensureDir(artifactsDir);\n \n // Process compiled contracts\n for (const [sourceFile, contracts] of Object.entries(output.contracts)) {\n for (const [contractName, contract] of Object.entries(contracts as any)) {\n console.log(`Compiled contract: ${contractName}`);\n \n // Write the ABI\n const abiPath = join(abiDir, `${contractName}.json`);\n writeFileSync(abiPath, JSON.stringify((contract as any).abi, null, 2));\n console.log(`ABI saved to ${abiPath}`);\n \n // Write the bytecode\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n writeFileSync(bytecodePath, (contract as any).evm.bytecode.object);\n console.log(`Bytecode saved to ${bytecodePath}`);\n }\n }\n } catch (error) {\n console.error('Error compiling contracts:', error);\n }\n};\n\nconst solidityFilePath: string = './contracts/Storage.sol';\nconst abiDir: string = './abis';\nconst artifactsDir: string = './artifacts';\n\ncompileContract(solidityFilePath, abiDir, artifactsDir);\n```\n\nTo compile your contract:\n\n```bash\nnpm run compile\n```\n\nAfter executing this script, you will see the compilation results including the generated `Storage.json` (containing the contract's ABI) and `Storage.bin` (containing the compiled bytecode)."} +{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 11, "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 10553, "end_char": 13178, "estimated_token_count": 610, "token_estimator": "heuristic-v1", "text": "## Deploy the Contract\n\nCreate a new file at `src/deploy.ts` for handling contract deployment:\n\n```typescript title=\"src/deploy.ts\"\nimport { existsSync, readFileSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { createWallet } from './createWallet.ts';\nimport { publicClient } from './createClient.ts';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst ABIS_DIR = join(__dirname, '../abis');\nconst ARTIFACTS_DIR = join(__dirname, '../artifacts');\n\nconst deployContract = async (\n contractName: string,\n privateKey: `0x${string}`\n) => {\n try {\n console.log(`Deploying ${contractName}...`);\n\n const abiPath = join(ABIS_DIR, `${contractName}.json`);\n const bytecodePath = join(ARTIFACTS_DIR, `${contractName}.bin`);\n\n if (!existsSync(abiPath) || !existsSync(bytecodePath)) {\n throw new Error(\n `Missing artifacts for ${contractName}. Try running \"npm run compile\" first.`\n );\n }\n\n // Read contract artifacts\n const abi = JSON.parse(\n readFileSync(abiPath, 'utf8')\n );\n const bytecode = `0x${readFileSync(bytecodePath, 'utf8').trim()}` as `0x${string}`;\n\n // Create wallet\n const wallet = createWallet(privateKey);\n\n // Deploy contract\n const hash = await wallet.deployContract({\n abi,\n bytecode,\n args: [], // Add constructor arguments if needed\n });\n\n // Wait for deployment\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const contractAddress = receipt.contractAddress;\n\n console.log(`Contract deployed at: ${contractAddress}`);\n return contractAddress;\n } catch (error) {\n console.error('Deployment failed:', error);\n throw error;\n }\n};\n\nconst privateKey = 'INSERT_PRIVATE_KEY';\ndeployContract('Storage', privateKey);\n```\n\nEnsure to replace `INSERT_PRIVATE_KEY` with the proper value. For further details on private key exportation, refer to the article [How to export an account's private key](https://support.metamask.io/configure/accounts/how-to-export-an-accounts-private-key/){target=\\_blank}.\n\n!!! warning\n Never commit or share your private key. Exposed keys can lead to immediate theft of all associated funds. Use environment variables instead.\n\nTo deploy, run the following command:\n\n```bash\nnpm run deploy\n```\n\nIf everything is successful, you will see the address of your deployed contract displayed in the terminal. This address is unique to your contract on the network you defined in the chain configuration, and you'll need it for any future interactions with your contract."} +{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 12, "depth": 2, "title": "Interact with the Contract", "anchor": "interact-with-the-contract", "start_char": 13178, "end_char": 15551, "estimated_token_count": 510, "token_estimator": "heuristic-v1", "text": "## Interact with the Contract\n\nCreate a new file at `src/interact.ts` for interacting with your deployed contract:\n\n```typescript title=\"src/interact.ts\"\nimport { readFileSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { publicClient } from './createClient.ts';\nimport { createWallet } from './createWallet.ts';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst ABI_PATH = join(__dirname, '../abis/Storage.json');\n\nconst STORAGE_ABI = JSON.parse(readFileSync(ABI_PATH, 'utf8'));\n\nconst interactWithStorage = async (\n contractAddress: `0x${string}`,\n privateKey: `0x${string}`\n) => {\n try {\n const wallet = createWallet(privateKey);\n const currentNumber = await publicClient.readContract({\n address: contractAddress,\n abi: STORAGE_ABI,\n functionName: 'storedNumber',\n args: [],\n });\n console.log(`Stored number: ${currentNumber}`);\n\n const newNumber = BigInt(42);\n const { request } = await publicClient.simulateContract({\n address: contractAddress,\n abi: STORAGE_ABI,\n functionName: 'setNumber',\n args: [newNumber],\n account: wallet.account,\n });\n\n const hash = await wallet.writeContract(request);\n await publicClient.waitForTransactionReceipt({ hash });\n console.log(`Number updated to ${newNumber}`);\n\n const updatedNumber = await publicClient.readContract({\n address: contractAddress,\n abi: STORAGE_ABI,\n functionName: 'storedNumber',\n args: [],\n });\n console.log('Updated stored number:', updatedNumber);\n } catch (error) {\n console.error('Interaction failed:', error);\n }\n};\n\nconst PRIVATE_KEY = 'INSERT_PRIVATE_KEY';\nconst CONTRACT_ADDRESS = 'INSERT_CONTRACT_ADDRESS';\n\ninteractWithStorage(CONTRACT_ADDRESS, PRIVATE_KEY);\n```\n\nEnsure to replace `INSERT_PRIVATE_KEY` and `INSERT_CONTRACT_ADDRESS` with the proper values.\n\nTo interact with the contract:\n\n```bash\nnpm run interact\n```\n\nFollowing a successful interaction, you will see the stored value before and after the transaction. The output will show the initial stored number (0 if you haven't modified it yet), confirm when the transaction to set the number to 42 is complete, and then display the updated stored number value. This demonstrates both reading from and writing to your smart contract."} +{"page_id": "smart-contracts-libraries-viem", "page_title": "viem for Polkadot Hub Smart Contracts", "index": 13, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 15551, "end_char": 17320, "estimated_token_count": 545, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nNow that you have the foundation for using viem with Polkadot Hub, consider exploring:\n\n
\n\n- External __Advanced viem Features__\n\n ---\n Explore viem's documentation:\n
    \n
  • [:octicons-arrow-right-24: Multi call](https://viem.sh/docs/contract/multicall#multicall){target=\\_blank}
  • \n\n
  • [:octicons-arrow-right-24: Batch transactions](https://viem.sh/docs/clients/transports/http#batch-json-rpc){target=\\_blank}
  • \n\n
  • [:octicons-arrow-right-24: Custom actions](https://viem.sh/docs/clients/custom#extending-with-actions-or-configuration){target=\\_blank}
  • \n
\n\n- External __Test Frameworks__\n\n ---\n\n Integrate viem with the following frameworks for comprehensive testing:\n
    \n
  • [:octicons-arrow-right-24: Hardhat](https://hardhat.org/){target=\\_blank}
  • \n\n
  • [:octicons-arrow-right-24: Foundry](https://getfoundry.sh/){target=\\_blank}
  • \n
\n\n- External __Event Handling__\n\n ---\n\n Learn how to subscribe to and process contract events:\n
    \n
  • [:octicons-arrow-right-24: Event subscription](https://viem.sh/docs/actions/public/watchEvent#watchevent){target=\\_blank}
  • \n
\n\n- External __Building dApps__\n\n ---\n\n Combine viem the following technologies to create full-stack applications:\n
    \n
  • [:octicons-arrow-right-24: Next.js](https://nextjs.org/docs){target=\\_blank}
  • \n\n
  • [:octicons-arrow-right-24: Node.js](https://nodejs.org/en){target=\\_blank}
  • \n
\n\n
"} {"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 9, "end_char": 437, "estimated_token_count": 97, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[Wagmi](https://wagmi.sh/){target=\\_blank} is a collection of [React Hooks](https://wagmi.sh/react/api/hooks){target=\\_blank} for interacting with Ethereum-compatible blockchains, focusing on developer experience, feature richness, and reliability.\n\nThis guide demonstrates how to use Wagmi to interact with and deploy smart contracts to Polkadot Hub, providing a seamless frontend integration for your dApps."} {"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 1, "depth": 2, "title": "Set Up the Project", "anchor": "set-up-the-project", "start_char": 437, "end_char": 668, "estimated_token_count": 55, "token_estimator": "heuristic-v1", "text": "## Set Up the Project\n\nTo start working with Wagmi, create a new React project and initialize it by running the following commands in your terminal:\n\n```bash\nnpx create-next-app@latest wagmi-polkadot-hub\ncd wagmi-polkadot-hub\n```"} {"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 2, "depth": 2, "title": "Install Dependencies", "anchor": "install-dependencies", "start_char": 668, "end_char": 798, "estimated_token_count": 31, "token_estimator": "heuristic-v1", "text": "## Install Dependencies\n\nInstall Wagmi v3 and its peer dependencies:\n\n```bash\nnpm install wagmi@3 viem @tanstack/react-query\n```"} -{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 3, "depth": 2, "title": "Configure Wagmi for Polkadot Hub", "anchor": "configure-wagmi-for-polkadot-hub", "start_char": 798, "end_char": 2532, "estimated_token_count": 392, "token_estimator": "heuristic-v1", "text": "## Configure Wagmi for Polkadot Hub\n\nCreate a configuration file to initialize Wagmi with Polkadot Hub. In your project, create a file named `app/lib/wagmi.ts` and add the code below. Be sure to replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, `INSERT_CHAIN_NAME`, `INSERT_NETWORK_NAME`, `INSERT_CHAIN_DECIMALS`, `INSERT_CURRENCY_NAME`, and `INSERT_CURRENCY_SYMBOL` with your specific values.\n\n```typescript title=\"app/lib/wagmi.ts\"\nimport { http, createConfig } from 'wagmi'\n\n// Configure the Polkadot Hub chain\nconst assetHub = {\n id: INSERT_CHAIN_ID,\n name: 'INSERT_CHAIN_NAME',\n network: 'INSERT_NETWORK_NAME',\n nativeCurrency: {\n decimals: INSERT_CHAIN_DECIMALS,\n name: 'INSERT_CURRENCY_NAME',\n symbol: 'INSERT_CURRENCY_SYMBOL',\n },\n rpcUrls: {\n default: {\n http: ['INSERT_RPC_URL'],\n },\n },\n} as const;\n\n// Create Wagmi config\nexport const config = createConfig({\n chains: [assetHub],\n transports: {\n [assetHub.id]: http(),\n },\n})\n```\n\n??? code \"Example Polkadot Hub TestNet Configuration\"\n\n ```typescript title=\"src/lib/wagmi.ts\"\n import { http, createConfig } from 'wagmi';\n\n // Configure the Polkadot Hub chain\n const assetHub = {\n id: 420420422,\n name: 'polkadot-hub-testnet',\n network: 'polkadot-hub-testnet',\n nativeCurrency: {\n decimals: 18,\n name: 'PAS',\n symbol: 'PAS',\n },\n rpcUrls: {\n default: {\n http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready\n },\n },\n } as const;\n\n // Create wagmi config\n export const config = createConfig({\n chains: [assetHub],\n transports: {\n [assetHub.id]: http(),\n },\n });\n ```"} -{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 4, "depth": 2, "title": "Set Up the Wagmi Provider", "anchor": "set-up-the-wagmi-provider", "start_char": 2532, "end_char": 3576, "estimated_token_count": 263, "token_estimator": "heuristic-v1", "text": "## Set Up the Wagmi Provider\n\nTo enable Wagmi in your React application, you need to wrap your app with the [`WagmiProvider`](https://wagmi.sh/react/api/WagmiProvider#wagmiprovider){target=\\_blank}. Update your `app/layout.tsx` file (for Next.js app router) with the following code:\n\n```typescript title=\"app/layout.tsx\"\n// For app router (src/app/layout.tsx)\n\"use client\";\n\nimport { WagmiProvider } from \"wagmi\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { config } from \"./lib/wagmi\";\n\n// Create a query client\nconst queryClient = new QueryClient();\n\nexport default function RootLayout({\n children,\n}: {\n children: React.ReactNode;\n}) {\n return (\n \n \n \n \n {children}\n \n \n \n \n );\n}\n\n```\n\n!!!note\n If you are using a Next.js pages router, you should modify the `src/pages/_app.tsx` instead."} -{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 5, "depth": 2, "title": "Connect a Wallet", "anchor": "connect-a-wallet", "start_char": 3576, "end_char": 5105, "estimated_token_count": 382, "token_estimator": "heuristic-v1", "text": "## Connect a Wallet\n\nCreate a component to connect wallets to your dApp. Create a file named `app/components/ConnectWallet.tsx`:\n\n```typescript title=\"app/components/ConnectWallet.tsx\"\n\"use client\";\n\nimport React from \"react\";\nimport { useConnect, useConnection, useDisconnect } from \"wagmi\";\nimport { injected } from \"wagmi/connectors\";\n\nexport function ConnectWallet() {\n const { connect } = useConnect();\n const { address, isConnected } = useConnection();\n const { disconnect } = useDisconnect();\n\n if (isConnected) {\n return (\n
\n
Connected to {address}
\n \n
\n );\n }\n\n return (\n \n );\n}\n\n```\n\nThis component uses the following React hooks:\n\n- **[`useConnect`](https://wagmi.sh/react/api/hooks/useConnect#useconnect){target=\\_blank}**: Provides functions and state for connecting the user's wallet to your dApp. The `connect` function initiates the connection flow with the specified connector.\n- **[`useDisconnect`](https://wagmi.sh/react/api/hooks/useDisconnect#usedisconnect){target=\\_blank}**: Provides a function to disconnect the currently connected wallet.\n- **[`useConnection`](https://wagmi.sh/react/api/hooks/useConnection#useconnection){target=\\_blank}**: Returns data about the connected account, including the address and connection status. In Wagmi v3, `useAccount` has been renamed to `useConnection`."} -{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 6, "depth": 2, "title": "Fetch Blockchain Data", "anchor": "fetch-blockchain-data", "start_char": 5105, "end_char": 6591, "estimated_token_count": 359, "token_estimator": "heuristic-v1", "text": "## Fetch Blockchain Data\n\nWagmi provides various hooks to fetch blockchain data. Here's an example component that demonstrates some of these hooks:\n\n```typescript title=\"app/components/BlockchainInfo.tsx\"\n\"use client\";\n\nimport { useBlockNumber, useBalance, useConnection } from \"wagmi\";\n\nexport function BlockchainInfo() {\n const { address } = useConnection();\n // Get the latest block number\n const { data: blockNumber } = useBlockNumber({ watch: true });\n\n // Get balance for the connected wallet\n const { data: balance } = useBalance({\n address,\n });\n\n return (\n
\n

Blockchain Information

\n
\n

Current Block: {blockNumber?.toString() || \"Loading...\"}

\n\n {address && balance && (\n

\n Balance:{\" \"}\n {(\n BigInt(balance.value) / BigInt(10 ** balance.decimals)\n ).toLocaleString()}{\" \"}\n {balance.symbol}\n

\n )}\n
\n
\n );\n}\n\n```\n\nThis component uses the following React hooks:\n\n- **[`useBlockNumber`](https://wagmi.sh/react/api/hooks/useBlockNumber#useBlockNumber){target=\\_blank}**: Fetches the current block number of the connected chain. The `watch` parameter enables real-time updates when new blocks are mined.\n- **[`useBalance`](https://wagmi.sh/react/api/hooks/useBalance#useBalance){target=\\_blank}**: Retrieves the native token balance for a specified address, including value, symbol, and decimals information."} -{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 7, "depth": 2, "title": "Interact with Deployed Contract", "anchor": "interact-with-deployed-contract", "start_char": 6591, "end_char": 11034, "estimated_token_count": 984, "token_estimator": "heuristic-v1", "text": "## Interact with Deployed Contract\n\nThis guide uses a simple Storage contract already deployed to the Polkadot Hub TestNet. The code of that contract is:\n\n??? code \"Storage.sol\"\n\n ```solidity title=\"Storage.sol\"\n //SPDX-License-Identifier: MIT\n\n // Solidity files have to start with this pragma.\n // It will be used by the Solidity compiler to validate its version.\n pragma solidity ^0.8.9;\n\n contract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n }\n ```\n\nCreate a component to interact with your deployed contract. Create a file named `app/components/StorageContract.tsx`:\n\n```typescript title=\"app/components/StorageContract.tsx\"\n\"use client\";\n\nimport { useState } from \"react\";\nimport {\n useReadContract,\n useWriteContract,\n useWaitForTransactionReceipt,\n} from \"wagmi\";\n\nconst CONTRACT_ADDRESS =\n \"INSERT_CONTRACT_ADDRESS\" as `0x${string}`;\n\nexport function StorageContract() {\n const [number, setNumber] = useState(\"42\");\n\n // Contract ABI (should match your compiled contract)\n const abi = [\n {\n inputs: [],\n name: \"storedNumber\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint256\", name: \"_newNumber\", type: \"uint256\" },\n ],\n name: \"setNumber\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n ];\n\n // Read the current stored number\n const { data: storedNumber, refetch } = useReadContract({\n address: CONTRACT_ADDRESS,\n abi,\n functionName: \"storedNumber\",\n });\n\n // Write to the contract\n const { writeContract, data: hash, error, isPending } = useWriteContract();\n\n // Wait for transaction to be mined\n const { isLoading: isConfirming, isSuccess: isConfirmed } =\n useWaitForTransactionReceipt({\n hash,\n });\n\n const handleSetNumber = () => {\n writeContract({\n address: CONTRACT_ADDRESS,\n abi,\n functionName: \"setNumber\",\n args: [BigInt(number)],\n });\n };\n\n return (\n
\n

Storage Contract Interaction

\n
\n

Contract Address: {CONTRACT_ADDRESS}

\n

Current Stored Number: {storedNumber?.toString() || \"Loading...\"}

\n
\n\n
\n setNumber(e.target.value)}\n disabled={isPending || isConfirming}\n />\n \n
\n\n {error &&
Error: {error.message}
}\n\n {isConfirmed && (\n
\n Successfully updated!{\" \"}\n \n
\n )}\n
\n );\n}\n\n```\n\nThis component demonstrates how to interact with a smart contract using Wagmi's hooks:\n\n- **[`useReadContract`](https://wagmi.sh/react/api/hooks/useReadContract#useReadContract){target=\\_blank}**: Calls a read-only function on your smart contract to retrieve data without modifying the blockchain state.\n- **[`useWriteContract`](https://wagmi.sh/react/api/hooks/useWriteContract#useWriteContract){target=\\_blank}**: Calls a state-modifying function on your smart contract, which requires a transaction to be signed and sent.\n- **[`useWaitForTransactionReceipt`](https://wagmi.sh/react/api/hooks/useWaitForTransactionReceipt#useWaitForTransactionReceipt){target=\\_blank}**: Tracks the status of a transaction after it's been submitted, allowing you to know when it's been confirmed.\n\nThe component also includes proper state handling to:\n\n- Show the current value stored in the contract.\n- Allow users to input a new value.\n- Display transaction status (pending, confirming, or completed).\n- Handle errors.\n- Provide feedback when a transaction is successful."} -{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 8, "depth": 2, "title": "Integrate Components", "anchor": "integrate-components", "start_char": 11034, "end_char": 11792, "estimated_token_count": 183, "token_estimator": "heuristic-v1", "text": "## Integrate Components\n\nUpdate your main page to combine all the components. Create or update the file `src/app/page.tsx`:\n\n```typescript title=\"src/app/page.tsx\"\n\"use client\";\n\nimport { BlockchainInfo } from \"./components/BlockchainInfo\";\nimport { ConnectWallet } from \"./components/ConnectWallet\";\nimport { StorageContract } from \"./components/StorageContract\";\nimport { useConnection } from \"wagmi\";\n\nexport default function Home() {\n const { isConnected } = useConnection();\n\n return (\n
\n

Wagmi - Polkadot Hub Smart Contracts

\n \n {isConnected ? : Connect your wallet}\n {isConnected ? : Connect your wallet}\n
\n );\n}\n\n```"} -{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 9, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 11792, "end_char": 13435, "estimated_token_count": 512, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nNow that you have the foundational knowledge to use Wagmi with Polkadot Hub, consider exploring:\n\n
\n\n- External __Advanced Wagmi__\n\n ---\n\n Explore Wagmi's advanced features:\n\n
    \n
  • [:octicons-arrow-right-24: Watch Contract Events](https://wagmi.sh/core/api/actions/watchContractEvent#eventname){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: Different Transports](https://wagmi.sh/react/api/transports){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: Actions](https://wagmi.sh/react/api/actions){target=\\_blank}
  • \n
\n\n- External __Wallet Integration__\n\n ---\n\n Connect your dApp with popular wallet providers:\n\n
    \n
  • [:octicons-arrow-right-24: MetaMask](https://wagmi.sh/core/api/connectors/metaMask){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: WalletConnect](https://wagmi.sh/core/api/connectors/walletConnect){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: Coinbase Wallet](https://wagmi.sh/core/api/connectors/coinbaseWallet){target=\\_blank}
  • \n
\n\n- External __Testing & Development__\n\n ---\n\n Enhance your development workflow:\n\n
    \n
  • [:octicons-arrow-right-24: Test Suite](https://wagmi.sh/dev/contributing#_6-running-the-test-suite){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: Dev Playground](https://wagmi.sh/dev/contributing#_5-running-the-dev-playgrounds){target=\\_blank}
  • \n
\n
"} +{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 3, "depth": 2, "title": "Configure Wagmi for Polkadot Hub", "anchor": "configure-wagmi-for-polkadot-hub", "start_char": 798, "end_char": 2484, "estimated_token_count": 377, "token_estimator": "heuristic-v1", "text": "## Configure Wagmi for Polkadot Hub\n\nCreate a configuration file to initialize Wagmi with Polkadot Hub. In your project, create a file named `app/lib/wagmi.ts` and add the code below. Be sure to replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, `INSERT_CHAIN_NAME`, `INSERT_NETWORK_NAME`, `INSERT_CHAIN_DECIMALS`, `INSERT_CURRENCY_NAME`, and `INSERT_CURRENCY_SYMBOL` with your specific values.\n\n```typescript title=\"app/lib/wagmi.ts\"\nimport { http, createConfig } from 'wagmi'\n\n// Configure the Polkadot Hub chain\nconst assetHub = {\n id: INSERT_CHAIN_ID,\n name: 'INSERT_CHAIN_NAME',\n network: 'INSERT_NETWORK_NAME',\n nativeCurrency: {\n decimals: INSERT_CHAIN_DECIMALS,\n name: 'INSERT_CURRENCY_NAME',\n symbol: 'INSERT_CURRENCY_SYMBOL',\n },\n rpcUrls: {\n default: {\n http: ['INSERT_RPC_URL'],\n },\n },\n} as const;\n\n// Create Wagmi config\nexport const config = createConfig({\n chains: [assetHub],\n transports: {\n [assetHub.id]: http(),\n },\n})\n```\n\n??? code \"Example Polkadot Hub TestNet Configuration\"\n\n ```typescript title=\"src/lib/wagmi.ts\"\n import { http, createConfig } from 'wagmi';\n\n // Configure the Polkadot Hub chain\n const assetHub = {\n id: 420420417,\n name: 'polkadot-hub-testnet',\n network: 'polkadot-hub-testnet',\n nativeCurrency: {\n decimals: 18,\n name: 'PAS',\n symbol: 'PAS',\n },\n rpcUrls: {\n default: {\n http: ['https://services.polkadothub-rpc.com/testnet'],\n },\n },\n } as const;\n\n // Create wagmi config\n export const config = createConfig({\n chains: [assetHub],\n transports: {\n [assetHub.id]: http(),\n },\n });\n ```"} +{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 4, "depth": 2, "title": "Set Up the Wagmi Provider", "anchor": "set-up-the-wagmi-provider", "start_char": 2484, "end_char": 3528, "estimated_token_count": 263, "token_estimator": "heuristic-v1", "text": "## Set Up the Wagmi Provider\n\nTo enable Wagmi in your React application, you need to wrap your app with the [`WagmiProvider`](https://wagmi.sh/react/api/WagmiProvider#wagmiprovider){target=\\_blank}. Update your `app/layout.tsx` file (for Next.js app router) with the following code:\n\n```typescript title=\"app/layout.tsx\"\n// For app router (src/app/layout.tsx)\n\"use client\";\n\nimport { WagmiProvider } from \"wagmi\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { config } from \"./lib/wagmi\";\n\n// Create a query client\nconst queryClient = new QueryClient();\n\nexport default function RootLayout({\n children,\n}: {\n children: React.ReactNode;\n}) {\n return (\n \n \n \n \n {children}\n \n \n \n \n );\n}\n\n```\n\n!!!note\n If you are using a Next.js pages router, you should modify the `src/pages/_app.tsx` instead."} +{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 5, "depth": 2, "title": "Connect a Wallet", "anchor": "connect-a-wallet", "start_char": 3528, "end_char": 5057, "estimated_token_count": 382, "token_estimator": "heuristic-v1", "text": "## Connect a Wallet\n\nCreate a component to connect wallets to your dApp. Create a file named `app/components/ConnectWallet.tsx`:\n\n```typescript title=\"app/components/ConnectWallet.tsx\"\n\"use client\";\n\nimport React from \"react\";\nimport { useConnect, useConnection, useDisconnect } from \"wagmi\";\nimport { injected } from \"wagmi/connectors\";\n\nexport function ConnectWallet() {\n const { connect } = useConnect();\n const { address, isConnected } = useConnection();\n const { disconnect } = useDisconnect();\n\n if (isConnected) {\n return (\n
\n
Connected to {address}
\n \n
\n );\n }\n\n return (\n \n );\n}\n\n```\n\nThis component uses the following React hooks:\n\n- **[`useConnect`](https://wagmi.sh/react/api/hooks/useConnect#useconnect){target=\\_blank}**: Provides functions and state for connecting the user's wallet to your dApp. The `connect` function initiates the connection flow with the specified connector.\n- **[`useDisconnect`](https://wagmi.sh/react/api/hooks/useDisconnect#usedisconnect){target=\\_blank}**: Provides a function to disconnect the currently connected wallet.\n- **[`useConnection`](https://wagmi.sh/react/api/hooks/useConnection#useconnection){target=\\_blank}**: Returns data about the connected account, including the address and connection status. In Wagmi v3, `useAccount` has been renamed to `useConnection`."} +{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 6, "depth": 2, "title": "Fetch Blockchain Data", "anchor": "fetch-blockchain-data", "start_char": 5057, "end_char": 6543, "estimated_token_count": 359, "token_estimator": "heuristic-v1", "text": "## Fetch Blockchain Data\n\nWagmi provides various hooks to fetch blockchain data. Here's an example component that demonstrates some of these hooks:\n\n```typescript title=\"app/components/BlockchainInfo.tsx\"\n\"use client\";\n\nimport { useBlockNumber, useBalance, useConnection } from \"wagmi\";\n\nexport function BlockchainInfo() {\n const { address } = useConnection();\n // Get the latest block number\n const { data: blockNumber } = useBlockNumber({ watch: true });\n\n // Get balance for the connected wallet\n const { data: balance } = useBalance({\n address,\n });\n\n return (\n
\n

Blockchain Information

\n
\n

Current Block: {blockNumber?.toString() || \"Loading...\"}

\n\n {address && balance && (\n

\n Balance:{\" \"}\n {(\n BigInt(balance.value) / BigInt(10 ** balance.decimals)\n ).toLocaleString()}{\" \"}\n {balance.symbol}\n

\n )}\n
\n
\n );\n}\n\n```\n\nThis component uses the following React hooks:\n\n- **[`useBlockNumber`](https://wagmi.sh/react/api/hooks/useBlockNumber#useBlockNumber){target=\\_blank}**: Fetches the current block number of the connected chain. The `watch` parameter enables real-time updates when new blocks are mined.\n- **[`useBalance`](https://wagmi.sh/react/api/hooks/useBalance#useBalance){target=\\_blank}**: Retrieves the native token balance for a specified address, including value, symbol, and decimals information."} +{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 7, "depth": 2, "title": "Interact with Deployed Contract", "anchor": "interact-with-deployed-contract", "start_char": 6543, "end_char": 10986, "estimated_token_count": 984, "token_estimator": "heuristic-v1", "text": "## Interact with Deployed Contract\n\nThis guide uses a simple Storage contract already deployed to the Polkadot Hub TestNet. The code of that contract is:\n\n??? code \"Storage.sol\"\n\n ```solidity title=\"Storage.sol\"\n //SPDX-License-Identifier: MIT\n\n // Solidity files have to start with this pragma.\n // It will be used by the Solidity compiler to validate its version.\n pragma solidity ^0.8.9;\n\n contract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n }\n ```\n\nCreate a component to interact with your deployed contract. Create a file named `app/components/StorageContract.tsx`:\n\n```typescript title=\"app/components/StorageContract.tsx\"\n\"use client\";\n\nimport { useState } from \"react\";\nimport {\n useReadContract,\n useWriteContract,\n useWaitForTransactionReceipt,\n} from \"wagmi\";\n\nconst CONTRACT_ADDRESS =\n \"INSERT_CONTRACT_ADDRESS\" as `0x${string}`;\n\nexport function StorageContract() {\n const [number, setNumber] = useState(\"42\");\n\n // Contract ABI (should match your compiled contract)\n const abi = [\n {\n inputs: [],\n name: \"storedNumber\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint256\", name: \"_newNumber\", type: \"uint256\" },\n ],\n name: \"setNumber\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n ];\n\n // Read the current stored number\n const { data: storedNumber, refetch } = useReadContract({\n address: CONTRACT_ADDRESS,\n abi,\n functionName: \"storedNumber\",\n });\n\n // Write to the contract\n const { writeContract, data: hash, error, isPending } = useWriteContract();\n\n // Wait for transaction to be mined\n const { isLoading: isConfirming, isSuccess: isConfirmed } =\n useWaitForTransactionReceipt({\n hash,\n });\n\n const handleSetNumber = () => {\n writeContract({\n address: CONTRACT_ADDRESS,\n abi,\n functionName: \"setNumber\",\n args: [BigInt(number)],\n });\n };\n\n return (\n
\n

Storage Contract Interaction

\n
\n

Contract Address: {CONTRACT_ADDRESS}

\n

Current Stored Number: {storedNumber?.toString() || \"Loading...\"}

\n
\n\n
\n setNumber(e.target.value)}\n disabled={isPending || isConfirming}\n />\n \n
\n\n {error &&
Error: {error.message}
}\n\n {isConfirmed && (\n
\n Successfully updated!{\" \"}\n \n
\n )}\n
\n );\n}\n\n```\n\nThis component demonstrates how to interact with a smart contract using Wagmi's hooks:\n\n- **[`useReadContract`](https://wagmi.sh/react/api/hooks/useReadContract#useReadContract){target=\\_blank}**: Calls a read-only function on your smart contract to retrieve data without modifying the blockchain state.\n- **[`useWriteContract`](https://wagmi.sh/react/api/hooks/useWriteContract#useWriteContract){target=\\_blank}**: Calls a state-modifying function on your smart contract, which requires a transaction to be signed and sent.\n- **[`useWaitForTransactionReceipt`](https://wagmi.sh/react/api/hooks/useWaitForTransactionReceipt#useWaitForTransactionReceipt){target=\\_blank}**: Tracks the status of a transaction after it's been submitted, allowing you to know when it's been confirmed.\n\nThe component also includes proper state handling to:\n\n- Show the current value stored in the contract.\n- Allow users to input a new value.\n- Display transaction status (pending, confirming, or completed).\n- Handle errors.\n- Provide feedback when a transaction is successful."} +{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 8, "depth": 2, "title": "Integrate Components", "anchor": "integrate-components", "start_char": 10986, "end_char": 11744, "estimated_token_count": 183, "token_estimator": "heuristic-v1", "text": "## Integrate Components\n\nUpdate your main page to combine all the components. Create or update the file `src/app/page.tsx`:\n\n```typescript title=\"src/app/page.tsx\"\n\"use client\";\n\nimport { BlockchainInfo } from \"./components/BlockchainInfo\";\nimport { ConnectWallet } from \"./components/ConnectWallet\";\nimport { StorageContract } from \"./components/StorageContract\";\nimport { useConnection } from \"wagmi\";\n\nexport default function Home() {\n const { isConnected } = useConnection();\n\n return (\n
\n

Wagmi - Polkadot Hub Smart Contracts

\n \n {isConnected ? : Connect your wallet}\n {isConnected ? : Connect your wallet}\n
\n );\n}\n\n```"} +{"page_id": "smart-contracts-libraries-wagmi", "page_title": "Wagmi for Polkadot Hub Smart Contracts", "index": 9, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 11744, "end_char": 13387, "estimated_token_count": 512, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nNow that you have the foundational knowledge to use Wagmi with Polkadot Hub, consider exploring:\n\n
\n\n- External __Advanced Wagmi__\n\n ---\n\n Explore Wagmi's advanced features:\n\n
    \n
  • [:octicons-arrow-right-24: Watch Contract Events](https://wagmi.sh/core/api/actions/watchContractEvent#eventname){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: Different Transports](https://wagmi.sh/react/api/transports){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: Actions](https://wagmi.sh/react/api/actions){target=\\_blank}
  • \n
\n\n- External __Wallet Integration__\n\n ---\n\n Connect your dApp with popular wallet providers:\n\n
    \n
  • [:octicons-arrow-right-24: MetaMask](https://wagmi.sh/core/api/connectors/metaMask){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: WalletConnect](https://wagmi.sh/core/api/connectors/walletConnect){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: Coinbase Wallet](https://wagmi.sh/core/api/connectors/coinbaseWallet){target=\\_blank}
  • \n
\n\n- External __Testing & Development__\n\n ---\n\n Enhance your development workflow:\n\n
    \n
  • [:octicons-arrow-right-24: Test Suite](https://wagmi.sh/dev/contributing#_6-running-the-test-suite){target=\\_blank}
  • \n
  • [:octicons-arrow-right-24: Dev Playground](https://wagmi.sh/dev/contributing#_5-running-the-dev-playgrounds){target=\\_blank}
  • \n
\n
"} {"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 298, "end_char": 857, "estimated_token_count": 102, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nInteracting with blockchains typically requires an interface between your application and the network. [Web3.js](https://web3js.readthedocs.io/){target=\\_blank} offers this interface through a comprehensive collection of libraries, facilitating seamless interaction with the nodes using HTTP or WebSocket protocols. This guide illustrates how to utilize Web3.js specifically for interactions with Polkadot Hub.\n\nThis guide is intended for developers who are familiar with JavaScript and want to interact with the Polkadot Hub using Web3.js."} {"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 857, "end_char": 1213, "estimated_token_count": 110, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore getting started, ensure you have the following installed:\n\n- **Node.js**: v22.13.1 or later, check the [Node.js installation guide](https://nodejs.org/en/download/current/){target=\\_blank}.\n- **npm**: v6.13.4 or later (comes bundled with Node.js).\n- **Solidity**: This guide uses Solidity `^0.8.9` for smart contract development."} {"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 2, "depth": 2, "title": "Project Structure", "anchor": "project-structure", "start_char": 1213, "end_char": 1691, "estimated_token_count": 135, "token_estimator": "heuristic-v1", "text": "## Project Structure\n\nThis project organizes contracts, scripts, and compiled artifacts for easy development and deployment.\n\n```text\nweb3js-project\nβ”œβ”€β”€ contracts\nβ”‚ β”œβ”€β”€ Storage.sol\nβ”œβ”€β”€ scripts\nβ”‚ β”œβ”€β”€ connectToProvider.js\nβ”‚ β”œβ”€β”€ fetchLastBlock.js\nβ”‚ β”œβ”€β”€ compile.js\nβ”‚ β”œβ”€β”€ deploy.js\nβ”‚ β”œβ”€β”€ updateStorage.js\nβ”œβ”€β”€ abis\nβ”‚ β”œβ”€β”€ Storage.json\nβ”œβ”€β”€ artifacts\nβ”‚ β”œβ”€β”€ Storage.bin\nβ”œβ”€β”€ contract-address.json\nβ”œβ”€β”€ node_modules/\nβ”œβ”€β”€ package.json\nβ”œβ”€β”€ package-lock.json\n└── README.md\n```"} {"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 3, "depth": 2, "title": "Set Up the Project", "anchor": "set-up-the-project", "start_char": 1691, "end_char": 1910, "estimated_token_count": 50, "token_estimator": "heuristic-v1", "text": "## Set Up the Project\n\nTo start working with Web3.js, create a new folder and initialize your project by running the following commands in your terminal:\n\n```bash\nmkdir web3js-project\ncd web3js-project\nnpm init -y\n```"} {"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 4, "depth": 2, "title": "Install Dependencies", "anchor": "install-dependencies", "start_char": 1910, "end_char": 2141, "estimated_token_count": 55, "token_estimator": "heuristic-v1", "text": "## Install Dependencies\n\nNext, run the following command to install the Web3.js library:\n\n```bash\nnpm install web3\n```\n\nAdd the Solidity compiler so you can generate standard EVM bytecode:\n\n```bash\nnpm install --save-dev solc\n```"} -{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 5, "depth": 2, "title": "Set Up the Web3 Provider", "anchor": "set-up-the-web3-provider", "start_char": 2141, "end_char": 4335, "estimated_token_count": 500, "token_estimator": "heuristic-v1", "text": "## Set Up the Web3 Provider\n\nThe provider configuration is the foundation of any Web3.js application. It serves as a bridge between your application and the blockchain, allowing you to query blockchain data and interact with smart contracts.\n\nTo interact with Polkadot Hub, you must set up a Web3.js provider. This provider connects to a blockchain node, allowing you to query blockchain data and interact with smart contracts. In the `scripts` directory of your project, create a file named `connectToProvider.js` and add the following code:\n\n```js title=\"scripts/connectToProvider.js\"\nconst { Web3 } = require('web3');\n\nconst createProvider = (rpcUrl) => {\n const web3 = new Web3(rpcUrl);\n return web3;\n};\n\nconst PROVIDER_RPC = {\n rpc: 'INSERT_RPC_URL',\n chainId: 'INSERT_CHAIN_ID',\n name: 'INSERT_CHAIN_NAME',\n};\n\ncreateProvider(PROVIDER_RPC.rpc);\n\n```\n\n!!! note\n Replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, and `INSERT_CHAIN_NAME` with the appropriate values. For example, to connect to Polkadot Hub TestNet's Ethereum RPC instance, you can use the following parameters:\n\n ```js\n const PROVIDER_RPC = {\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n chainId: 420420422,\n name: 'polkadot-hub-testnet'\n };\n ```\n\nTo connect to the provider, execute:\n\n```bash\nnode scripts/connectToProvider.js\n```\n\nWith the provider set up, you can start querying the blockchain. For instance, to fetch the latest block number.\n\n??? code \"Fetch last block example\"\n\n ```js title=\"scripts/fetchLastBlock.js\"\n const { Web3 } = require('web3');\n\n const createProvider = (rpcUrl) => {\n const web3 = new Web3(rpcUrl);\n return web3;\n };\n\n const PROVIDER_RPC = {\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n chainId: 420420422,\n name: 'polkadotTestNet',\n };\n\n const main = async () => {\n try {\n const web3 = createProvider(PROVIDER_RPC.rpc);\n const latestBlock = await web3.eth.getBlockNumber();\n console.log('Last block: ' + latestBlock);\n } catch (error) {\n console.error('Error connecting to Polkadot Hub TestNet: ' + error.message);\n }\n };\n\n main();\n\n ```"} -{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 6, "depth": 2, "title": "Compile Contracts", "anchor": "compile-contracts", "start_char": 4335, "end_char": 4662, "estimated_token_count": 74, "token_estimator": "heuristic-v1", "text": "## Compile Contracts\n\nPolkadot Hub exposes an Ethereum JSON-RPC endpoint, so you can compile Solidity contracts to familiar EVM bytecode with the upstream [`solc`](https://www.npmjs.com/package/solc){target=\\_blank} compiler. The resulting artifacts work with any EVM-compatible toolchain and can be deployed through Web3.js."} -{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 7, "depth": 3, "title": "Sample Storage Smart Contract", "anchor": "sample-storage-smart-contract", "start_char": 4662, "end_char": 5367, "estimated_token_count": 145, "token_estimator": "heuristic-v1", "text": "### Sample Storage Smart Contract\n\nThis example demonstrates compiling a `Storage.sol` Solidity contract for deployment to Polkadot Hub. The contract's functionality stores a number and permits users to update it with a new value.\n\n```solidity title=\"contracts/Storage.sol\"\n//SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\ncontract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n}\n```"} -{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 8, "depth": 3, "title": "Compile the Smart Contract", "anchor": "compile-the-smart-contract", "start_char": 5367, "end_char": 8924, "estimated_token_count": 810, "token_estimator": "heuristic-v1", "text": "### Compile the Smart Contract\n\nTo compile this contract, use the following script:\n\n```js title=\"scripts/compile.js\"\nconst solc = require('solc');\nconst { readFileSync, writeFileSync, mkdirSync, existsSync } = require('fs');\nconst { basename, join } = require('path');\n\nconst ensureDir = (dirPath) => {\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n }\n};\n\nconst compileContract = (solidityFilePath, abiDir, artifactsDir) => {\n try {\n // Read the Solidity file\n const source = readFileSync(solidityFilePath, 'utf8');\n const fileName = basename(solidityFilePath);\n \n // Construct the input object for the Solidity compiler\n const input = {\n language: 'Solidity',\n sources: {\n [fileName]: {\n content: source,\n },\n },\n settings: {\n outputSelection: {\n '*': {\n '*': ['abi', 'evm.bytecode'],\n },\n },\n },\n };\n \n console.log(`Compiling contract: ${fileName}...`);\n \n // Compile the contract\n const output = JSON.parse(solc.compile(JSON.stringify(input)));\n \n // Check for errors\n if (output.errors) {\n const errors = output.errors.filter(error => error.severity === 'error');\n if (errors.length > 0) {\n console.error('Compilation errors:');\n errors.forEach(err => console.error(err.formattedMessage));\n return;\n }\n // Show warnings\n const warnings = output.errors.filter(error => error.severity === 'warning');\n warnings.forEach(warn => console.warn(warn.formattedMessage));\n }\n \n // Ensure output directories exist\n ensureDir(abiDir);\n ensureDir(artifactsDir);\n\n // Process compiled contracts\n for (const [sourceFile, contracts] of Object.entries(output.contracts)) {\n for (const [contractName, contract] of Object.entries(contracts)) {\n console.log(`Compiled contract: ${contractName}`);\n \n // Write the ABI\n const abiPath = join(abiDir, `${contractName}.json`);\n writeFileSync(abiPath, JSON.stringify(contract.abi, null, 2));\n console.log(`ABI saved to ${abiPath}`);\n \n // Write the bytecode\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n writeFileSync(bytecodePath, contract.evm.bytecode.object);\n console.log(`Bytecode saved to ${bytecodePath}`);\n }\n }\n } catch (error) {\n console.error('Error compiling contracts:', error);\n }\n};\n\nconst solidityFilePath = join(__dirname, '../contracts/Storage.sol');\nconst abiDir = join(__dirname, '../abis');\nconst artifactsDir = join(__dirname, '../artifacts');\n\ncompileContract(solidityFilePath, abiDir, artifactsDir);\n```\n\n!!! note \n The script above is tailored to the `Storage.sol` contract. It can be adjusted for other contracts by changing the file name or modifying the ABI and bytecode paths.\n\nThe ABI (Application Binary Interface) is a JSON representation of your contract's functions, events, and their parameters. It serves as the interface between your JavaScript code and the deployed smart contract, allowing your application to know how to format function calls and interpret returned data.\n\nExecute the script above by running:\n\n```bash\nnode scripts/compile.js\n```\n\nAfter executing the script, the Solidity contract is compiled into standard EVM bytecode. The ABI and bytecode are saved into files with `.json` and `.bin` extensions, respectively. You can now proceed with deploying the contract to Polkadot Hub, as outlined in the next section."} -{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 9, "depth": 2, "title": "Deploy the Compiled Contract", "anchor": "deploy-the-compiled-contract", "start_char": 8924, "end_char": 16998, "estimated_token_count": 1793, "token_estimator": "heuristic-v1", "text": "## Deploy the Compiled Contract\n\nTo deploy your compiled contract to Polkadot Hub, you'll need a wallet with a private key to sign the deployment transaction.\n\nYou can create a `deploy.js` script in the `scripts` directory of your project to achieve this. The deployment script can be divided into key components:\n\n1. Set up the required imports and utilities:\n\n ```js title=\"scripts/deploy.js\"\n const { writeFileSync, existsSync, readFileSync } = require('fs');\n const { join } = require('path');\n const { Web3 } = require('web3');\n\n const scriptsDir = __dirname;\n const abisDir = join(__dirname, '../abis');\n const artifactsDir = join(__dirname, '../artifacts');\n ```\n\n2. Create a provider to connect to Polkadot Hub:\n\n ```js title=\"scripts/deploy.js\"\n const createProvider = (rpcUrl, chainId, chainName) => {\n const web3 = new Web3(rpcUrl);\n return web3;\n };\n ```\n\n3. Set up functions to read contract artifacts:\n\n ```js title=\"scripts/deploy.js\"\n const getAbi = (contractName) => {\n try {\n const abiPath = join(abisDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n const getByteCode = (contractName) => {\n try {\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n const bytecode = readFileSync(bytecodePath, 'utf8').trim();\n return bytecode.startsWith('0x') ? bytecode : `0x${bytecode}`;\n } catch (error) {\n console.error(\n `Could not find bytecode for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n ```\n\n4. Create the main deployment function:\n\n ```js title=\"scripts/deploy.js\"\n const deployContract = async (contractName, privateKey, providerConfig) => {\n console.log(`Deploying ${contractName}...`);\n try {\n const web3 = createProvider(\n providerConfig.rpc,\n providerConfig.chainId,\n providerConfig.name,\n );\n\n const formattedPrivateKey = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`;\n const account = web3.eth.accounts.privateKeyToAccount(formattedPrivateKey);\n web3.eth.accounts.wallet.add(account);\n web3.eth.defaultAccount = account.address;\n\n const abi = getAbi(contractName);\n const bytecode = getByteCode(contractName);\n const contract = new web3.eth.Contract(abi);\n const deployTx = contract.deploy({\n data: bytecode,\n });\n\n const gas = await deployTx.estimateGas();\n const gasPrice = await web3.eth.getGasPrice();\n\n console.log(`Estimated gas: ${gas}`);\n console.log(`Gas price: ${web3.utils.fromWei(gasPrice, 'gwei')} gwei`);\n\n const deployedContract = await deployTx.send({\n from: account.address,\n gas: gas,\n gasPrice: gasPrice,\n });\n\n const address = deployedContract.options.address;\n console.log(`Contract ${contractName} deployed at: ${address}`);\n\n const addressesFile = join(scriptsDir, 'contract-address.json');\n const addresses = existsSync(addressesFile)\n ? JSON.parse(readFileSync(addressesFile, 'utf8'))\n : {};\n\n addresses[contractName] = address;\n writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');\n } catch (error) {\n console.error(`Failed to deploy contract ${contractName}:`, error);\n }\n };\n ```\n\n5. Configure and execute the deployment:\n\n ```js title=\"scripts/deploy.js\"\n const providerConfig = {\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready\n chainId: 420420422,\n name: 'polkadotTestNet',\n };\n\n const privateKey = 'INSERT_PRIVATE_KEY';\n\n deployContract('Storage', privateKey, providerConfig);\n ```\n\n !!! note\n\n A private key is a hexadecimal string that is used to sign and pay for the deployment transaction. **Always keep your private key secure and never share it publicly**.\n\n Ensure to replace the `INSERT_PRIVATE_KEY` placeholder with your actual private key.\n\n??? code \"View complete script\"\n\n ```js title=\"scripts/deploy.js\"\n const { writeFileSync, existsSync, readFileSync } = require('fs');\n const { join } = require('path');\n const { Web3 } = require('web3');\n\n const scriptsDir = __dirname;\n const abisDir = join(__dirname, '../abis');\n const artifactsDir = join(__dirname, '../artifacts');\n\n const createProvider = (rpcUrl, chainId, chainName) => {\n const web3 = new Web3(rpcUrl);\n return web3;\n };\n\n const getAbi = (contractName) => {\n try {\n const abiPath = join(abisDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n const getByteCode = (contractName) => {\n try {\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n const bytecode = readFileSync(bytecodePath, 'utf8').trim();\n return bytecode.startsWith('0x') ? bytecode : `0x${bytecode}`;\n } catch (error) {\n console.error(\n `Could not find bytecode for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n const deployContract = async (contractName, privateKey, providerConfig) => {\n console.log(`Deploying ${contractName}...`);\n try {\n const web3 = createProvider(\n providerConfig.rpc,\n providerConfig.chainId,\n providerConfig.name,\n );\n\n const formattedPrivateKey = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`;\n const account = web3.eth.accounts.privateKeyToAccount(formattedPrivateKey);\n web3.eth.accounts.wallet.add(account);\n web3.eth.defaultAccount = account.address;\n\n const abi = getAbi(contractName);\n const bytecode = getByteCode(contractName);\n const contract = new web3.eth.Contract(abi);\n const deployTx = contract.deploy({\n data: bytecode,\n });\n\n const gas = await deployTx.estimateGas();\n const gasPrice = await web3.eth.getGasPrice();\n\n console.log(`Estimated gas: ${gas}`);\n console.log(`Gas price: ${web3.utils.fromWei(gasPrice, 'gwei')} gwei`);\n\n const deployedContract = await deployTx.send({\n from: account.address,\n gas: gas,\n gasPrice: gasPrice,\n });\n\n const address = deployedContract.options.address;\n console.log(`Contract ${contractName} deployed at: ${address}`);\n\n const addressesFile = join(scriptsDir, 'contract-address.json');\n const addresses = existsSync(addressesFile)\n ? JSON.parse(readFileSync(addressesFile, 'utf8'))\n : {};\n\n addresses[contractName] = address;\n writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');\n } catch (error) {\n console.error(`Failed to deploy contract ${contractName}:`, error);\n }\n };\n\n const providerConfig = {\n rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', // TODO: replace to `https://services.polkadothub-rpc.com/testnet` when ready\n chainId: 420420422,\n name: 'polkadotTestNet',\n };\n\n const privateKey = 'INSERT_PRIVATE_KEY';\n\n deployContract('Storage', privateKey, providerConfig);\n\n\n ```\n\nTo run the script, execute the following command:\n\n```bash\nnode scripts/deploy.js\n```\n\nAfter running this script, your contract will be deployed to Polkadot Hub, and its address will be saved in `contract-address.json` within your project directory. You can use this address for future contract interactions."} -{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 10, "depth": 2, "title": "Interact with the Contract", "anchor": "interact-with-the-contract", "start_char": 16998, "end_char": 19676, "estimated_token_count": 646, "token_estimator": "heuristic-v1", "text": "## Interact with the Contract\n\nOnce the contract is deployed, you can interact with it by calling its functions. For example, to read the current stored value and then update it to a new value, you can create a file named `updateStorage.js` in the `scripts` directory of your project and add the following code:\n\n```js title=\"scripts/updateStorage.js\"\nconst { readFileSync } = require('fs');\nconst { join } = require('path');\nconst { Web3 } = require('web3');\n\nconst abisDir = join(__dirname, '../abis');\n\nconst getAbi = (contractName) => {\n try {\n const abiPath = join(abisDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n};\n\nconst updateStorage = async (config) => {\n try {\n const web3 = new Web3(config.rpcUrl);\n const formattedPrivateKey = config.privateKey.startsWith('0x') ? config.privateKey : `0x${config.privateKey}`;\n const account = web3.eth.accounts.privateKeyToAccount(formattedPrivateKey);\n web3.eth.accounts.wallet.add(account);\n\n const abi = getAbi('Storage');\n const contract = new web3.eth.Contract(abi, config.contractAddress);\n\n const initialValue = await contract.methods.storedNumber().call();\n console.log('Current stored value:', initialValue);\n\n const updateTransaction = contract.methods.setNumber(1);\n const gasEstimate = await updateTransaction.estimateGas({\n from: account.address,\n });\n const gasPrice = await web3.eth.getGasPrice();\n\n const receipt = await updateTransaction.send({\n from: account.address,\n gas: gasEstimate,\n gasPrice: gasPrice,\n });\n\n console.log(`Transaction hash: ${receipt.transactionHash}`);\n\n const newValue = await contract.methods.storedNumber().call();\n console.log('New stored value:', newValue);\n\n return receipt;\n } catch (error) {\n console.error('Update failed:', error);\n throw error;\n }\n};\n\nconst config = {\n rpcUrl: 'https://testnet-passet-hub-eth-rpc.polkadot.io',\n privateKey: 'INSERT_PRIVATE_KEY',\n contractAddress: 'INSERT_CONTRACT_ADDRESS',\n};\n\nupdateStorage(config)\n .then((receipt) => console.log('Update successful'))\n .catch((error) => console.error('Update error'));\n```\n\nEnsure you replace the `INSERT_PRIVATE_KEY` and `INSERT_CONTRACT_ADDRESS` placeholders with actual values. Also, ensure the contract ABI file (`Storage.json`) is correctly referenced. The script reads the current stored value, sets it to 1, and then displays the updated value.\n\nTo interact with the contract, run:\n\n```bash\nnode scripts/updateStorage.js\n```"} -{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 11, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 19676, "end_char": 20077, "estimated_token_count": 110, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- External __Web3.js Docs__\n\n ---\n\n Explore the Web3.js documentation to learn how to use additional features, such as wallet management, signing messages, subscribing to events, and more.\n\n [:octicons-arrow-right-24: Get Started](https://web3js.readthedocs.io/en/v1.10.0/){target=\\_blank}\n\n
"} +{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 5, "depth": 2, "title": "Set Up the Web3 Provider", "anchor": "set-up-the-web3-provider", "start_char": 2141, "end_char": 4331, "estimated_token_count": 492, "token_estimator": "heuristic-v1", "text": "## Set Up the Web3 Provider\n\nThe provider configuration is the foundation of any Web3.js application. It serves as a bridge between your application and the blockchain, allowing you to query blockchain data and interact with smart contracts.\n\nTo interact with Polkadot Hub, you must set up a Web3.js provider. This provider connects to a blockchain node, allowing you to query blockchain data and interact with smart contracts. In the `scripts` directory of your project, create a file named `connectToProvider.js` and add the following code:\n\n```js title=\"scripts/connectToProvider.js\"\nconst { Web3 } = require('web3');\n\nconst createProvider = (rpcUrl) => {\n const web3 = new Web3(rpcUrl);\n return web3;\n};\n\nconst PROVIDER_RPC = {\n rpc: 'INSERT_RPC_URL',\n chainId: 'INSERT_CHAIN_ID',\n name: 'INSERT_CHAIN_NAME',\n};\n\ncreateProvider(PROVIDER_RPC.rpc);\n\n```\n\n!!! note\n Replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, and `INSERT_CHAIN_NAME` with the appropriate values. For example, to connect to Polkadot Hub TestNet's Ethereum RPC instance, you can use the following parameters:\n\n ```js\n const PROVIDER_RPC = {\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n name: 'polkadot-hub-testnet'\n };\n ```\n\nTo connect to the provider, execute:\n\n```bash\nnode scripts/connectToProvider.js\n```\n\nWith the provider set up, you can start querying the blockchain. For instance, to fetch the latest block number.\n\n??? code \"Fetch last block example\"\n\n ```js title=\"scripts/fetchLastBlock.js\"\n const { Web3 } = require('web3');\n\n const createProvider = (rpcUrl) => {\n const web3 = new Web3(rpcUrl);\n return web3;\n };\n\n const PROVIDER_RPC = {\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n name: 'polkadotTestNet',\n };\n\n const main = async () => {\n try {\n const web3 = createProvider(PROVIDER_RPC.rpc);\n const latestBlock = await web3.eth.getBlockNumber();\n console.log('Last block: ' + latestBlock);\n } catch (error) {\n console.error('Error connecting to Polkadot Hub TestNet: ' + error.message);\n }\n };\n\n main();\n\n ```"} +{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 6, "depth": 2, "title": "Compile Contracts", "anchor": "compile-contracts", "start_char": 4331, "end_char": 4658, "estimated_token_count": 74, "token_estimator": "heuristic-v1", "text": "## Compile Contracts\n\nPolkadot Hub exposes an Ethereum JSON-RPC endpoint, so you can compile Solidity contracts to familiar EVM bytecode with the upstream [`solc`](https://www.npmjs.com/package/solc){target=\\_blank} compiler. The resulting artifacts work with any EVM-compatible toolchain and can be deployed through Web3.js."} +{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 7, "depth": 3, "title": "Sample Storage Smart Contract", "anchor": "sample-storage-smart-contract", "start_char": 4658, "end_char": 5363, "estimated_token_count": 145, "token_estimator": "heuristic-v1", "text": "### Sample Storage Smart Contract\n\nThis example demonstrates compiling a `Storage.sol` Solidity contract for deployment to Polkadot Hub. The contract's functionality stores a number and permits users to update it with a new value.\n\n```solidity title=\"contracts/Storage.sol\"\n//SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\ncontract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n}\n```"} +{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 8, "depth": 3, "title": "Compile the Smart Contract", "anchor": "compile-the-smart-contract", "start_char": 5363, "end_char": 8920, "estimated_token_count": 810, "token_estimator": "heuristic-v1", "text": "### Compile the Smart Contract\n\nTo compile this contract, use the following script:\n\n```js title=\"scripts/compile.js\"\nconst solc = require('solc');\nconst { readFileSync, writeFileSync, mkdirSync, existsSync } = require('fs');\nconst { basename, join } = require('path');\n\nconst ensureDir = (dirPath) => {\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n }\n};\n\nconst compileContract = (solidityFilePath, abiDir, artifactsDir) => {\n try {\n // Read the Solidity file\n const source = readFileSync(solidityFilePath, 'utf8');\n const fileName = basename(solidityFilePath);\n \n // Construct the input object for the Solidity compiler\n const input = {\n language: 'Solidity',\n sources: {\n [fileName]: {\n content: source,\n },\n },\n settings: {\n outputSelection: {\n '*': {\n '*': ['abi', 'evm.bytecode'],\n },\n },\n },\n };\n \n console.log(`Compiling contract: ${fileName}...`);\n \n // Compile the contract\n const output = JSON.parse(solc.compile(JSON.stringify(input)));\n \n // Check for errors\n if (output.errors) {\n const errors = output.errors.filter(error => error.severity === 'error');\n if (errors.length > 0) {\n console.error('Compilation errors:');\n errors.forEach(err => console.error(err.formattedMessage));\n return;\n }\n // Show warnings\n const warnings = output.errors.filter(error => error.severity === 'warning');\n warnings.forEach(warn => console.warn(warn.formattedMessage));\n }\n \n // Ensure output directories exist\n ensureDir(abiDir);\n ensureDir(artifactsDir);\n\n // Process compiled contracts\n for (const [sourceFile, contracts] of Object.entries(output.contracts)) {\n for (const [contractName, contract] of Object.entries(contracts)) {\n console.log(`Compiled contract: ${contractName}`);\n \n // Write the ABI\n const abiPath = join(abiDir, `${contractName}.json`);\n writeFileSync(abiPath, JSON.stringify(contract.abi, null, 2));\n console.log(`ABI saved to ${abiPath}`);\n \n // Write the bytecode\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n writeFileSync(bytecodePath, contract.evm.bytecode.object);\n console.log(`Bytecode saved to ${bytecodePath}`);\n }\n }\n } catch (error) {\n console.error('Error compiling contracts:', error);\n }\n};\n\nconst solidityFilePath = join(__dirname, '../contracts/Storage.sol');\nconst abiDir = join(__dirname, '../abis');\nconst artifactsDir = join(__dirname, '../artifacts');\n\ncompileContract(solidityFilePath, abiDir, artifactsDir);\n```\n\n!!! note \n The script above is tailored to the `Storage.sol` contract. It can be adjusted for other contracts by changing the file name or modifying the ABI and bytecode paths.\n\nThe ABI (Application Binary Interface) is a JSON representation of your contract's functions, events, and their parameters. It serves as the interface between your JavaScript code and the deployed smart contract, allowing your application to know how to format function calls and interpret returned data.\n\nExecute the script above by running:\n\n```bash\nnode scripts/compile.js\n```\n\nAfter executing the script, the Solidity contract is compiled into standard EVM bytecode. The ABI and bytecode are saved into files with `.json` and `.bin` extensions, respectively. You can now proceed with deploying the contract to Polkadot Hub, as outlined in the next section."} +{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 9, "depth": 2, "title": "Deploy the Compiled Contract", "anchor": "deploy-the-compiled-contract", "start_char": 8920, "end_char": 16834, "estimated_token_count": 1739, "token_estimator": "heuristic-v1", "text": "## Deploy the Compiled Contract\n\nTo deploy your compiled contract to Polkadot Hub, you'll need a wallet with a private key to sign the deployment transaction.\n\nYou can create a `deploy.js` script in the `scripts` directory of your project to achieve this. The deployment script can be divided into key components:\n\n1. Set up the required imports and utilities:\n\n ```js title=\"scripts/deploy.js\"\n const { writeFileSync, existsSync, readFileSync } = require('fs');\n const { join } = require('path');\n const { Web3 } = require('web3');\n\n const scriptsDir = __dirname;\n const abisDir = join(__dirname, '../abis');\n const artifactsDir = join(__dirname, '../artifacts');\n ```\n\n2. Create a provider to connect to Polkadot Hub:\n\n ```js title=\"scripts/deploy.js\"\n const createProvider = (rpcUrl, chainId, chainName) => {\n const web3 = new Web3(rpcUrl);\n return web3;\n };\n ```\n\n3. Set up functions to read contract artifacts:\n\n ```js title=\"scripts/deploy.js\"\n const getAbi = (contractName) => {\n try {\n const abiPath = join(abisDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n const getByteCode = (contractName) => {\n try {\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n const bytecode = readFileSync(bytecodePath, 'utf8').trim();\n return bytecode.startsWith('0x') ? bytecode : `0x${bytecode}`;\n } catch (error) {\n console.error(\n `Could not find bytecode for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n ```\n\n4. Create the main deployment function:\n\n ```js title=\"scripts/deploy.js\"\n const deployContract = async (contractName, privateKey, providerConfig) => {\n console.log(`Deploying ${contractName}...`);\n try {\n const web3 = createProvider(\n providerConfig.rpc,\n providerConfig.chainId,\n providerConfig.name,\n );\n\n const formattedPrivateKey = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`;\n const account = web3.eth.accounts.privateKeyToAccount(formattedPrivateKey);\n web3.eth.accounts.wallet.add(account);\n web3.eth.defaultAccount = account.address;\n\n const abi = getAbi(contractName);\n const bytecode = getByteCode(contractName);\n const contract = new web3.eth.Contract(abi);\n const deployTx = contract.deploy({\n data: bytecode,\n });\n\n const gas = await deployTx.estimateGas();\n const gasPrice = await web3.eth.getGasPrice();\n\n console.log(`Estimated gas: ${gas}`);\n console.log(`Gas price: ${web3.utils.fromWei(gasPrice, 'gwei')} gwei`);\n\n const deployedContract = await deployTx.send({\n from: account.address,\n gas: gas,\n gasPrice: gasPrice,\n });\n\n const address = deployedContract.options.address;\n console.log(`Contract ${contractName} deployed at: ${address}`);\n\n const addressesFile = join(scriptsDir, 'contract-address.json');\n const addresses = existsSync(addressesFile)\n ? JSON.parse(readFileSync(addressesFile, 'utf8'))\n : {};\n\n addresses[contractName] = address;\n writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');\n } catch (error) {\n console.error(`Failed to deploy contract ${contractName}:`, error);\n }\n };\n ```\n\n5. Configure and execute the deployment:\n\n ```js title=\"scripts/deploy.js\"\n const providerConfig = {\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n name: 'polkadotTestNet',\n };\n\n const privateKey = 'INSERT_PRIVATE_KEY';\n\n deployContract('Storage', privateKey, providerConfig);\n ```\n\n !!! note\n\n A private key is a hexadecimal string that is used to sign and pay for the deployment transaction. **Always keep your private key secure and never share it publicly**.\n\n Ensure to replace the `INSERT_PRIVATE_KEY` placeholder with your actual private key.\n\n??? code \"View complete script\"\n\n ```js title=\"scripts/deploy.js\"\n const { writeFileSync, existsSync, readFileSync } = require('fs');\n const { join } = require('path');\n const { Web3 } = require('web3');\n\n const scriptsDir = __dirname;\n const abisDir = join(__dirname, '../abis');\n const artifactsDir = join(__dirname, '../artifacts');\n\n const createProvider = (rpcUrl, chainId, chainName) => {\n const web3 = new Web3(rpcUrl);\n return web3;\n };\n\n const getAbi = (contractName) => {\n try {\n const abiPath = join(abisDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n const getByteCode = (contractName) => {\n try {\n const bytecodePath = join(artifactsDir, `${contractName}.bin`);\n const bytecode = readFileSync(bytecodePath, 'utf8').trim();\n return bytecode.startsWith('0x') ? bytecode : `0x${bytecode}`;\n } catch (error) {\n console.error(\n `Could not find bytecode for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n };\n\n const deployContract = async (contractName, privateKey, providerConfig) => {\n console.log(`Deploying ${contractName}...`);\n try {\n const web3 = createProvider(\n providerConfig.rpc,\n providerConfig.chainId,\n providerConfig.name,\n );\n\n const formattedPrivateKey = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`;\n const account = web3.eth.accounts.privateKeyToAccount(formattedPrivateKey);\n web3.eth.accounts.wallet.add(account);\n web3.eth.defaultAccount = account.address;\n\n const abi = getAbi(contractName);\n const bytecode = getByteCode(contractName);\n const contract = new web3.eth.Contract(abi);\n const deployTx = contract.deploy({\n data: bytecode,\n });\n\n const gas = await deployTx.estimateGas();\n const gasPrice = await web3.eth.getGasPrice();\n\n console.log(`Estimated gas: ${gas}`);\n console.log(`Gas price: ${web3.utils.fromWei(gasPrice, 'gwei')} gwei`);\n\n const deployedContract = await deployTx.send({\n from: account.address,\n gas: gas,\n gasPrice: gasPrice,\n });\n\n const address = deployedContract.options.address;\n console.log(`Contract ${contractName} deployed at: ${address}`);\n\n const addressesFile = join(scriptsDir, 'contract-address.json');\n const addresses = existsSync(addressesFile)\n ? JSON.parse(readFileSync(addressesFile, 'utf8'))\n : {};\n\n addresses[contractName] = address;\n writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');\n } catch (error) {\n console.error(`Failed to deploy contract ${contractName}:`, error);\n }\n };\n\n const providerConfig = {\n rpc: 'https://services.polkadothub-rpc.com/testnet',\n chainId: 420420417,\n name: 'polkadotTestNet',\n };\n\n const privateKey = 'INSERT_PRIVATE_KEY';\n\n deployContract('Storage', privateKey, providerConfig);\n\n\n ```\n\nTo run the script, execute the following command:\n\n```bash\nnode scripts/deploy.js\n```\n\nAfter running this script, your contract will be deployed to Polkadot Hub, and its address will be saved in `contract-address.json` within your project directory. You can use this address for future contract interactions."} +{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 10, "depth": 2, "title": "Interact with the Contract", "anchor": "interact-with-the-contract", "start_char": 16834, "end_char": 19510, "estimated_token_count": 642, "token_estimator": "heuristic-v1", "text": "## Interact with the Contract\n\nOnce the contract is deployed, you can interact with it by calling its functions. For example, to read the current stored value and then update it to a new value, you can create a file named `updateStorage.js` in the `scripts` directory of your project and add the following code:\n\n```js title=\"scripts/updateStorage.js\"\nconst { readFileSync } = require('fs');\nconst { join } = require('path');\nconst { Web3 } = require('web3');\n\nconst abisDir = join(__dirname, '../abis');\n\nconst getAbi = (contractName) => {\n try {\n const abiPath = join(abisDir, `${contractName}.json`);\n return JSON.parse(readFileSync(abiPath, 'utf8'));\n } catch (error) {\n console.error(\n `Could not find ABI for contract ${contractName}:`,\n error.message,\n );\n throw error;\n }\n};\n\nconst updateStorage = async (config) => {\n try {\n const web3 = new Web3(config.rpcUrl);\n const formattedPrivateKey = config.privateKey.startsWith('0x') ? config.privateKey : `0x${config.privateKey}`;\n const account = web3.eth.accounts.privateKeyToAccount(formattedPrivateKey);\n web3.eth.accounts.wallet.add(account);\n\n const abi = getAbi('Storage');\n const contract = new web3.eth.Contract(abi, config.contractAddress);\n\n const initialValue = await contract.methods.storedNumber().call();\n console.log('Current stored value:', initialValue);\n\n const updateTransaction = contract.methods.setNumber(1);\n const gasEstimate = await updateTransaction.estimateGas({\n from: account.address,\n });\n const gasPrice = await web3.eth.getGasPrice();\n\n const receipt = await updateTransaction.send({\n from: account.address,\n gas: gasEstimate,\n gasPrice: gasPrice,\n });\n\n console.log(`Transaction hash: ${receipt.transactionHash}`);\n\n const newValue = await contract.methods.storedNumber().call();\n console.log('New stored value:', newValue);\n\n return receipt;\n } catch (error) {\n console.error('Update failed:', error);\n throw error;\n }\n};\n\nconst config = {\n rpcUrl: 'https://services.polkadothub-rpc.com/testnet',\n privateKey: 'INSERT_PRIVATE_KEY',\n contractAddress: 'INSERT_CONTRACT_ADDRESS',\n};\n\nupdateStorage(config)\n .then((receipt) => console.log('Update successful'))\n .catch((error) => console.error('Update error'));\n```\n\nEnsure you replace the `INSERT_PRIVATE_KEY` and `INSERT_CONTRACT_ADDRESS` placeholders with actual values. Also, ensure the contract ABI file (`Storage.json`) is correctly referenced. The script reads the current stored value, sets it to 1, and then displays the updated value.\n\nTo interact with the contract, run:\n\n```bash\nnode scripts/updateStorage.js\n```"} +{"page_id": "smart-contracts-libraries-web3-js", "page_title": "Deploy Contracts to Polkadot Hub with Web3.js", "index": 11, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 19510, "end_char": 19911, "estimated_token_count": 110, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- External __Web3.js Docs__\n\n ---\n\n Explore the Web3.js documentation to learn how to use additional features, such as wallet management, signing messages, subscribing to events, and more.\n\n [:octicons-arrow-right-24: Get Started](https://web3js.readthedocs.io/en/v1.10.0/){target=\\_blank}\n\n
"} {"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 11, "end_char": 435, "estimated_token_count": 83, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nInteracting with blockchains typically requires an interface between your application and the network. [Web3.py](https://web3py.readthedocs.io/en/stable/index.html){target=\\_blank} offers this interface through a collection of libraries, facilitating seamless interaction with the nodes using HTTP or WebSocket protocols. \n\nThis guide illustrates how to utilize Web3.py for interactions with Polkadot Hub."} {"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 1, "depth": 2, "title": "Set Up the Project", "anchor": "set-up-the-project", "start_char": 435, "end_char": 816, "estimated_token_count": 88, "token_estimator": "heuristic-v1", "text": "## Set Up the Project\n\n1. To start working with Web3.py, begin by initializing your project:\n\n ```bash\n mkdir web3py-project\n cd web3py-project\n ```\n\n2. Create and activate a virtual environment for your project:\n\n ```bash\n python -m venv venv\n source venv/bin/activate\n ```\n\n3. Next, install the Web3.py library:\n\n ```bash\n pip install web3\n ```"} -{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 2, "depth": 2, "title": "Set Up the Web3 Provider", "anchor": "set-up-the-web3-provider", "start_char": 816, "end_char": 2433, "estimated_token_count": 351, "token_estimator": "heuristic-v1", "text": "## Set Up the Web3 Provider\n\nThe [provider](https://web3py.readthedocs.io/en/stable/providers.html){target=\\_blank} configuration is the foundation of any Web3.py application. It serves as a bridge between your application and the blockchain, allowing you to query blockchain data and interact with smart contracts.\n\nTo interact with Polkadot Hub, you must set up a Web3.py provider. This provider connects to a blockchain node, allowing you to query blockchain data and interact with smart contracts. The following code sets up the provider configuration:\n\n```python\nfrom web3 import Web3\n\nPROVIDER_RPC = \"INSERT_RPC_URL\"\nweb3 = Web3(Web3.HTTPProvider(PROVIDER_RPC))\n\n```\n\n!!! note\n Replace `INSERT_RPC_URL` with the appropriate value. For instance, to connect to Polkadot Hub TestNet, use the following parameter:\n\n ```python\n PROVIDER_RPC = 'https://testnet-passet-hub-eth-rpc.polkadot.io'\n ```\n\nWith the Web3 provider set up, start querying the blockchain. For instance, you can use the following code snippet to fetch the latest block number of the chain.\n\n??? code \"Fetch last block example\"\n\n ```python title=\"fetch_last_block.py\"\n from web3 import Web3\n\n\n def main():\n try:\n PROVIDER_RPC = \"https://testnet-passet-hub-eth-rpc.polkadot.io\"\n web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC))\n latest_block = web3.eth.block_number\n print(\"Last block: \" + str(latest_block))\n except Exception as error:\n print(\"Error connecting to Polkadot Hub TestNet: \" + str(error))\n\n\n if __name__ == \"__main__\":\n main()\n\n ```"} -{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 3, "depth": 2, "title": "Compile Contracts", "anchor": "compile-contracts", "start_char": 2433, "end_char": 2837, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "## Compile Contracts\n\nPolkadot Hub exposes an Ethereum JSON-RPC endpoint, so you can compile Solidity contracts to familiar EVM bytecode with the [`py-solc-x`](https://solcx.readthedocs.io/en/latest/){target=\\_blank} compiler. The resulting artifacts work with any EVM-compatible toolchain and can be deployed through Web3.py.\n\nFirst, install the `py-solc-x` package:\n\n```bash\npip install py-solc-x\n```"} -{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 4, "depth": 3, "title": "Sample Storage Smart Contract", "anchor": "sample-storage-smart-contract", "start_char": 2837, "end_char": 3652, "estimated_token_count": 169, "token_estimator": "heuristic-v1", "text": "### Sample Storage Smart Contract\n\nThis example demonstrates compiling a `Storage.sol` Solidity contract for deployment to Polkadot Hub. The contract's functionality stores a number and permits users to update it with a new value.\n\n```solidity title=\"Storage.sol\"\n//SPDX-License-Identifier: MIT\n\n// Solidity files have to start with this pragma.\n// It will be used by the Solidity compiler to validate its version.\npragma solidity ^0.8.9;\n\ncontract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n}\n```"} -{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 5, "depth": 3, "title": "Compile the Smart Contract", "anchor": "compile-the-smart-contract", "start_char": 3652, "end_char": 5925, "estimated_token_count": 529, "token_estimator": "heuristic-v1", "text": "### Compile the Smart Contract\n\nTo compile this contract, create a Python script named `compile.py`:\n\n```python title=\"compile.py\"\nimport json\nimport solcx\nfrom pathlib import Path\n\nSOLC_VERSION = '0.8.9'\ntry:\n solcx.install_solc(SOLC_VERSION)\nexcept Exception as e:\n print(f\"Solc version {SOLC_VERSION} already installed or error: {e}\")\n\nsolcx.set_solc_version(SOLC_VERSION)\n\ncontract_path = Path('Storage.sol')\nwith open(contract_path, 'r') as file:\n contract_source = file.read()\n\ncompiled_sol = solcx.compile_source(\n contract_source,\n output_values=['abi', 'bin'],\n solc_version=SOLC_VERSION\n)\n\ncontract_id, contract_interface = compiled_sol.popitem()\n\nbytecode = contract_interface['bin']\nabi = contract_interface['abi']\n\nPath('abis').mkdir(exist_ok=True)\nPath('artifacts').mkdir(exist_ok=True)\n\nwith open('abis/Storage.json', 'w') as abi_file:\n json.dump(abi, abi_file, indent=2)\n\nwith open('artifacts/Storage.bin', 'w') as bin_file:\n bin_file.write(bytecode)\n\nprint(\"βœ… Contract compiled successfully!\")\nprint(f\"πŸ“„ ABI saved to: abis/Storage.json\")\nprint(f\"πŸ“¦ Bytecode saved to: artifacts/Storage.bin\")\n```\n\n!!! note \n The script above is tailored to the `Storage.sol` contract. It can be adjusted for other contracts by changing the file name or modifying the ABI and bytecode paths.\n\nThe ABI (Application Binary Interface) is a JSON representation of your contract's functions, events, and their parameters. It serves as the interface between your Python code and the deployed smart contract, allowing your application to know how to format function calls and interpret returned data.\n\nExecute the script by running:\n\n```bash\npython compile.py\n```\n\nAfter executing the script, the Solidity contract is compiled into standard EVM bytecode. The ABI and bytecode are saved into files with `.json` and `.bin` extensions, respectively:\n\n- **ABI file (`abis/Storage.json`)**: Provides a JSON interface describing the contract's functions and how to interact with it.\n- **Bytecode file (`artifacts/Storage.bin`)**: Contains the low-level machine code executable on EVM that represents the compiled smart contract ready for blockchain deployment.\n\nYou can now proceed with deploying the contract to Polkadot Hub, as outlined in the next section."} -{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 6, "depth": 2, "title": "Contract Deployment", "anchor": "contract-deployment", "start_char": 5925, "end_char": 11250, "estimated_token_count": 1073, "token_estimator": "heuristic-v1", "text": "## Contract Deployment\n\nTo deploy your compiled contract to Polkadot Hub using Web3.py, you'll need an account with a private key to sign the deployment transaction. The deployment process is exactly the same as for any Ethereum-compatible chain, involving creating a contract instance, estimating gas, and sending a deployment transaction. Here's how to deploy the contract. ReplaceΒ `INSERT_RPC_URL`Β andΒ `INSERT_PRIVATE_KEY` with the appropriate values:\n\n```python title=\"deploy.py\"\nfrom web3 import Web3\nimport json\nimport time\nfrom pathlib import Path\n\nARTIFACTS_DIR = Path(__file__).parent\nABI_DIR = ARTIFACTS_DIR / \"abis\"\nBYTECODE_DIR = ARTIFACTS_DIR / \"artifacts\"\n\ndef get_abi(contract_name):\n try:\n with open(ABI_DIR / f\"{contract_name}.json\", 'r') as file:\n return json.load(file)\n except Exception as error:\n print(f\"❌ Could not find ABI for contract {contract_name}: {error}\")\n raise error\n\ndef get_bytecode(contract_name):\n try:\n with open(BYTECODE_DIR / f\"{contract_name}.bin\", 'r') as file:\n bytecode = file.read().strip()\n return bytecode if bytecode.startswith('0x') else f\"0x{bytecode}\"\n except Exception as error:\n print(f\"❌ Could not find bytecode for contract {contract_name}: {error}\")\n raise error\n\ndef deploy_with_retry(config, max_retries=3):\n \"\"\"Deploy with retry logic for RPC errors\"\"\"\n for attempt in range(max_retries):\n try:\n return deploy(config)\n except Exception as error:\n error_str = str(error)\n if \"500\" in error_str or \"Internal Server Error\" in error_str or \"Connection\" in error_str:\n if attempt < max_retries - 1:\n wait_time = (attempt + 1) * 3\n print(f\"RPC error, retrying in {wait_time} seconds... (attempt {attempt + 1}/{max_retries})\")\n time.sleep(wait_time)\n continue\n raise error\n\ndef deploy(config):\n try:\n # Initialize Web3 with RPC URL and longer timeout\n web3 = Web3(Web3.HTTPProvider(\n config[\"rpc_url\"],\n request_kwargs={'timeout': 120}\n ))\n \n # Prepare account\n formatted_private_key = config[\"private_key\"] if config[\"private_key\"].startswith('0x') else f\"0x{config['private_key']}\"\n account = web3.eth.account.from_key(formatted_private_key)\n print(f\"Deploying from address: {account.address}\")\n \n # Load ABI and bytecode\n abi = get_abi('Storage')\n bytecode = get_bytecode('Storage')\n print(f\"Bytecode length: {len(bytecode)}\")\n \n # Create contract instance\n contract = web3.eth.contract(abi=abi, bytecode=bytecode)\n \n # Get current nonce (this will test the connection)\n print(\"Getting nonce...\")\n nonce = web3.eth.get_transaction_count(account.address)\n print(f\"Nonce: {nonce}\")\n \n # Estimate gas\n print(\"Estimating gas...\")\n gas_estimate = web3.eth.estimate_gas({\n 'from': account.address,\n 'data': bytecode\n })\n print(f\"Estimated gas: {gas_estimate}\")\n \n # Get gas price\n print(\"Getting gas price...\")\n gas_price = web3.eth.gas_price\n print(f\"Gas price: {web3.from_wei(gas_price, 'gwei')} gwei\")\n \n # Build deployment transaction\n print(\"Building transaction...\")\n construct_txn = contract.constructor().build_transaction({\n 'from': account.address,\n 'nonce': nonce,\n 'gas': gas_estimate,\n 'gasPrice': gas_price,\n })\n \n # Sign transaction\n print(\"Signing transaction...\")\n signed_txn = web3.eth.account.sign_transaction(construct_txn, private_key=formatted_private_key)\n \n # Send transaction\n print(\"Sending transaction...\")\n tx_hash = web3.eth.send_raw_transaction(signed_txn.raw_transaction)\n print(f\"Transaction hash: {tx_hash.hex()}\")\n \n # Wait for transaction receipt\n print(\"Waiting for transaction receipt...\")\n tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash, timeout=300)\n contract_address = tx_receipt.contractAddress\n \n # Log results\n print(f\"βœ… Contract deployed at: {contract_address}\")\n print(f\"Gas used: {tx_receipt.gasUsed}\")\n print(f\"Block number: {tx_receipt.blockNumber}\")\n \n return web3.eth.contract(address=contract_address, abi=abi)\n \n except Exception as error:\n print(f'❌ Deployment failed: {error}')\n raise error\n\nif __name__ == \"__main__\":\n deployment_config = {\n \"rpc_url\": \"https://testnet-passet-hub-eth-rpc.polkadot.io\",\n \"private_key\": \"0xd505c673c48556d560696d129f0e611f041638cd42d81c33ddc0e490cdcf65fc\"\n }\n \n deploy_with_retry(deployment_config)\n```\n\n!!!warning\n Never commit or share your private key. Exposed keys can lead to immediate theft of all associated funds.\n\nTo run the script, execute the following command:\n\n```bash\npython deploy.py\n```\n\nAfter running this script, your contract will be deployed to Polkadot Hub, and its address will be printed in your terminal. You can use this address for future contract interactions."} -{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 7, "depth": 2, "title": "Interact with the Contract", "anchor": "interact-with-the-contract", "start_char": 11250, "end_char": 13697, "estimated_token_count": 483, "token_estimator": "heuristic-v1", "text": "## Interact with the Contract\n\nAfter deployment, interact with your contract using Web3.py methods. The example below demonstrates how to set and retrieve a number.\n\n```python title=\"update_storage.py\"\nfrom web3 import Web3\nimport json\n\n\ndef get_abi(contract_name):\n try:\n with open(f\"{contract_name}.json\", \"r\") as file:\n return json.load(file)\n except Exception as error:\n print(f\"❌ Could not find ABI for contract {contract_name}: {error}\")\n raise error\n\n\nasync def update_storage(config):\n try:\n # Initialize Web3 with RPC URL\n web3 = Web3(Web3.HTTPProvider(config[\"rpc_url\"]))\n\n # Prepare account\n account = web3.eth.account.from_key(config[\"private_key\"])\n\n # Load ABI\n abi = get_abi(\"Storage\")\n\n # Create contract instance\n contract = web3.eth.contract(address=config[\"contract_address\"], abi=abi)\n\n # Get initial value\n initial_value = contract.functions.storedNumber().call()\n print(\"Current stored value:\", initial_value)\n\n # Get current nonce\n nonce = web3.eth.get_transaction_count(account.address)\n\n # Prepare transaction\n transaction = contract.functions.setNumber(1).build_transaction(\n {\"from\": account.address, \"nonce\": nonce}\n )\n\n # Sign transaction\n signed_txn = web3.eth.account.sign_transaction(\n transaction, private_key=config[\"private_key\"]\n )\n\n # Send transaction\n tx_hash = web3.eth.send_raw_transaction(signed_txn.raw_transaction)\n print(f\"Transaction hash: {tx_hash.hex()}\")\n\n # Wait for receipt\n receipt = web3.eth.wait_for_transaction_receipt(tx_hash)\n\n # Get updated value\n new_value = contract.functions.storedNumber().call()\n print(\"New stored value:\", new_value)\n\n return receipt\n\n except Exception as error:\n print(\"Update failed:\", error)\n raise error\n\n\nif __name__ == \"__main__\":\n # Example usage\n import asyncio\n\n config = {\n \"rpc_url\": \"INSERT_RPC_URL\",\n \"private_key\": \"INSERT_PRIVATE_KEY\",\n \"contract_address\": \"INSERT_CONTRACT_ADDRESS\",\n }\n\n asyncio.run(update_storage(config))\n\n```\n\nBe sure to replace the `INSERT_RPC_URL`, `INSERT_PRIVATE_KEY`, and `INSERT_CONTRACT_ADDRESS` placeholders with your specific values.\n\nTo interact with the contract, run:\n\n```bash\npython update_storage.py\n```"} -{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 8, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 13697, "end_char": 14097, "estimated_token_count": 106, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- External __Web3.py Docs__\n\n ---\n\n Explore the Web3.py documentation to learn how to use additional features, such as wallet management, signing messages, subscribing to events, and more.\n\n [:octicons-arrow-right-24: Get Started](https://web3py.readthedocs.io/en/stable/){target=\\_blank}\n\n
"} +{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 2, "depth": 2, "title": "Set Up the Web3 Provider", "anchor": "set-up-the-web3-provider", "start_char": 816, "end_char": 2429, "estimated_token_count": 343, "token_estimator": "heuristic-v1", "text": "## Set Up the Web3 Provider\n\nThe [provider](https://web3py.readthedocs.io/en/stable/providers.html){target=\\_blank} configuration is the foundation of any Web3.py application. It serves as a bridge between your application and the blockchain, allowing you to query blockchain data and interact with smart contracts.\n\nTo interact with Polkadot Hub, you must set up a Web3.py provider. This provider connects to a blockchain node, allowing you to query blockchain data and interact with smart contracts. The following code sets up the provider configuration:\n\n```python\nfrom web3 import Web3\n\nPROVIDER_RPC = \"INSERT_RPC_URL\"\nweb3 = Web3(Web3.HTTPProvider(PROVIDER_RPC))\n\n```\n\n!!! note\n Replace `INSERT_RPC_URL` with the appropriate value. For instance, to connect to Polkadot Hub TestNet, use the following parameter:\n\n ```python\n PROVIDER_RPC = 'https://services.polkadothub-rpc.com/testnet'\n ```\n\nWith the Web3 provider set up, start querying the blockchain. For instance, you can use the following code snippet to fetch the latest block number of the chain.\n\n??? code \"Fetch last block example\"\n\n ```python title=\"fetch_last_block.py\"\n from web3 import Web3\n\n\n def main():\n try:\n PROVIDER_RPC = \"https://services.polkadothub-rpc.com/testnet\"\n web3 = Web3(Web3.HTTPProvider(PROVIDER_RPC))\n latest_block = web3.eth.block_number\n print(\"Last block: \" + str(latest_block))\n except Exception as error:\n print(\"Error connecting to Polkadot Hub TestNet: \" + str(error))\n\n\n if __name__ == \"__main__\":\n main()\n\n ```"} +{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 3, "depth": 2, "title": "Compile Contracts", "anchor": "compile-contracts", "start_char": 2429, "end_char": 2833, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "## Compile Contracts\n\nPolkadot Hub exposes an Ethereum JSON-RPC endpoint, so you can compile Solidity contracts to familiar EVM bytecode with the [`py-solc-x`](https://solcx.readthedocs.io/en/latest/){target=\\_blank} compiler. The resulting artifacts work with any EVM-compatible toolchain and can be deployed through Web3.py.\n\nFirst, install the `py-solc-x` package:\n\n```bash\npip install py-solc-x\n```"} +{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 4, "depth": 3, "title": "Sample Storage Smart Contract", "anchor": "sample-storage-smart-contract", "start_char": 2833, "end_char": 3648, "estimated_token_count": 169, "token_estimator": "heuristic-v1", "text": "### Sample Storage Smart Contract\n\nThis example demonstrates compiling a `Storage.sol` Solidity contract for deployment to Polkadot Hub. The contract's functionality stores a number and permits users to update it with a new value.\n\n```solidity title=\"Storage.sol\"\n//SPDX-License-Identifier: MIT\n\n// Solidity files have to start with this pragma.\n// It will be used by the Solidity compiler to validate its version.\npragma solidity ^0.8.9;\n\ncontract Storage {\n // Public state variable to store a number\n uint256 public storedNumber;\n\n /**\n * Updates the stored number.\n *\n * The `public` modifier allows anyone to call this function.\n *\n * @param _newNumber - The new value to store.\n */\n function setNumber(uint256 _newNumber) public {\n storedNumber = _newNumber;\n }\n}\n```"} +{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 5, "depth": 3, "title": "Compile the Smart Contract", "anchor": "compile-the-smart-contract", "start_char": 3648, "end_char": 5921, "estimated_token_count": 529, "token_estimator": "heuristic-v1", "text": "### Compile the Smart Contract\n\nTo compile this contract, create a Python script named `compile.py`:\n\n```python title=\"compile.py\"\nimport json\nimport solcx\nfrom pathlib import Path\n\nSOLC_VERSION = '0.8.9'\ntry:\n solcx.install_solc(SOLC_VERSION)\nexcept Exception as e:\n print(f\"Solc version {SOLC_VERSION} already installed or error: {e}\")\n\nsolcx.set_solc_version(SOLC_VERSION)\n\ncontract_path = Path('Storage.sol')\nwith open(contract_path, 'r') as file:\n contract_source = file.read()\n\ncompiled_sol = solcx.compile_source(\n contract_source,\n output_values=['abi', 'bin'],\n solc_version=SOLC_VERSION\n)\n\ncontract_id, contract_interface = compiled_sol.popitem()\n\nbytecode = contract_interface['bin']\nabi = contract_interface['abi']\n\nPath('abis').mkdir(exist_ok=True)\nPath('artifacts').mkdir(exist_ok=True)\n\nwith open('abis/Storage.json', 'w') as abi_file:\n json.dump(abi, abi_file, indent=2)\n\nwith open('artifacts/Storage.bin', 'w') as bin_file:\n bin_file.write(bytecode)\n\nprint(\"βœ… Contract compiled successfully!\")\nprint(f\"πŸ“„ ABI saved to: abis/Storage.json\")\nprint(f\"πŸ“¦ Bytecode saved to: artifacts/Storage.bin\")\n```\n\n!!! note \n The script above is tailored to the `Storage.sol` contract. It can be adjusted for other contracts by changing the file name or modifying the ABI and bytecode paths.\n\nThe ABI (Application Binary Interface) is a JSON representation of your contract's functions, events, and their parameters. It serves as the interface between your Python code and the deployed smart contract, allowing your application to know how to format function calls and interpret returned data.\n\nExecute the script by running:\n\n```bash\npython compile.py\n```\n\nAfter executing the script, the Solidity contract is compiled into standard EVM bytecode. The ABI and bytecode are saved into files with `.json` and `.bin` extensions, respectively:\n\n- **ABI file (`abis/Storage.json`)**: Provides a JSON interface describing the contract's functions and how to interact with it.\n- **Bytecode file (`artifacts/Storage.bin`)**: Contains the low-level machine code executable on EVM that represents the compiled smart contract ready for blockchain deployment.\n\nYou can now proceed with deploying the contract to Polkadot Hub, as outlined in the next section."} +{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 6, "depth": 2, "title": "Contract Deployment", "anchor": "contract-deployment", "start_char": 5921, "end_char": 11246, "estimated_token_count": 1073, "token_estimator": "heuristic-v1", "text": "## Contract Deployment\n\nTo deploy your compiled contract to Polkadot Hub using Web3.py, you'll need an account with a private key to sign the deployment transaction. The deployment process is exactly the same as for any Ethereum-compatible chain, involving creating a contract instance, estimating gas, and sending a deployment transaction. Here's how to deploy the contract. ReplaceΒ `INSERT_RPC_URL`Β andΒ `INSERT_PRIVATE_KEY` with the appropriate values:\n\n```python title=\"deploy.py\"\nfrom web3 import Web3\nimport json\nimport time\nfrom pathlib import Path\n\nARTIFACTS_DIR = Path(__file__).parent\nABI_DIR = ARTIFACTS_DIR / \"abis\"\nBYTECODE_DIR = ARTIFACTS_DIR / \"artifacts\"\n\ndef get_abi(contract_name):\n try:\n with open(ABI_DIR / f\"{contract_name}.json\", 'r') as file:\n return json.load(file)\n except Exception as error:\n print(f\"❌ Could not find ABI for contract {contract_name}: {error}\")\n raise error\n\ndef get_bytecode(contract_name):\n try:\n with open(BYTECODE_DIR / f\"{contract_name}.bin\", 'r') as file:\n bytecode = file.read().strip()\n return bytecode if bytecode.startswith('0x') else f\"0x{bytecode}\"\n except Exception as error:\n print(f\"❌ Could not find bytecode for contract {contract_name}: {error}\")\n raise error\n\ndef deploy_with_retry(config, max_retries=3):\n \"\"\"Deploy with retry logic for RPC errors\"\"\"\n for attempt in range(max_retries):\n try:\n return deploy(config)\n except Exception as error:\n error_str = str(error)\n if \"500\" in error_str or \"Internal Server Error\" in error_str or \"Connection\" in error_str:\n if attempt < max_retries - 1:\n wait_time = (attempt + 1) * 3\n print(f\"RPC error, retrying in {wait_time} seconds... (attempt {attempt + 1}/{max_retries})\")\n time.sleep(wait_time)\n continue\n raise error\n\ndef deploy(config):\n try:\n # Initialize Web3 with RPC URL and longer timeout\n web3 = Web3(Web3.HTTPProvider(\n config[\"rpc_url\"],\n request_kwargs={'timeout': 120}\n ))\n \n # Prepare account\n formatted_private_key = config[\"private_key\"] if config[\"private_key\"].startswith('0x') else f\"0x{config['private_key']}\"\n account = web3.eth.account.from_key(formatted_private_key)\n print(f\"Deploying from address: {account.address}\")\n \n # Load ABI and bytecode\n abi = get_abi('Storage')\n bytecode = get_bytecode('Storage')\n print(f\"Bytecode length: {len(bytecode)}\")\n \n # Create contract instance\n contract = web3.eth.contract(abi=abi, bytecode=bytecode)\n \n # Get current nonce (this will test the connection)\n print(\"Getting nonce...\")\n nonce = web3.eth.get_transaction_count(account.address)\n print(f\"Nonce: {nonce}\")\n \n # Estimate gas\n print(\"Estimating gas...\")\n gas_estimate = web3.eth.estimate_gas({\n 'from': account.address,\n 'data': bytecode\n })\n print(f\"Estimated gas: {gas_estimate}\")\n \n # Get gas price\n print(\"Getting gas price...\")\n gas_price = web3.eth.gas_price\n print(f\"Gas price: {web3.from_wei(gas_price, 'gwei')} gwei\")\n \n # Build deployment transaction\n print(\"Building transaction...\")\n construct_txn = contract.constructor().build_transaction({\n 'from': account.address,\n 'nonce': nonce,\n 'gas': gas_estimate,\n 'gasPrice': gas_price,\n })\n \n # Sign transaction\n print(\"Signing transaction...\")\n signed_txn = web3.eth.account.sign_transaction(construct_txn, private_key=formatted_private_key)\n \n # Send transaction\n print(\"Sending transaction...\")\n tx_hash = web3.eth.send_raw_transaction(signed_txn.raw_transaction)\n print(f\"Transaction hash: {tx_hash.hex()}\")\n \n # Wait for transaction receipt\n print(\"Waiting for transaction receipt...\")\n tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash, timeout=300)\n contract_address = tx_receipt.contractAddress\n \n # Log results\n print(f\"βœ… Contract deployed at: {contract_address}\")\n print(f\"Gas used: {tx_receipt.gasUsed}\")\n print(f\"Block number: {tx_receipt.blockNumber}\")\n \n return web3.eth.contract(address=contract_address, abi=abi)\n \n except Exception as error:\n print(f'❌ Deployment failed: {error}')\n raise error\n\nif __name__ == \"__main__\":\n deployment_config = {\n \"rpc_url\": \"https://testnet-passet-hub-eth-rpc.polkadot.io\",\n \"private_key\": \"0xd505c673c48556d560696d129f0e611f041638cd42d81c33ddc0e490cdcf65fc\"\n }\n \n deploy_with_retry(deployment_config)\n```\n\n!!!warning\n Never commit or share your private key. Exposed keys can lead to immediate theft of all associated funds.\n\nTo run the script, execute the following command:\n\n```bash\npython deploy.py\n```\n\nAfter running this script, your contract will be deployed to Polkadot Hub, and its address will be printed in your terminal. You can use this address for future contract interactions."} +{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 7, "depth": 2, "title": "Interact with the Contract", "anchor": "interact-with-the-contract", "start_char": 11246, "end_char": 13693, "estimated_token_count": 483, "token_estimator": "heuristic-v1", "text": "## Interact with the Contract\n\nAfter deployment, interact with your contract using Web3.py methods. The example below demonstrates how to set and retrieve a number.\n\n```python title=\"update_storage.py\"\nfrom web3 import Web3\nimport json\n\n\ndef get_abi(contract_name):\n try:\n with open(f\"{contract_name}.json\", \"r\") as file:\n return json.load(file)\n except Exception as error:\n print(f\"❌ Could not find ABI for contract {contract_name}: {error}\")\n raise error\n\n\nasync def update_storage(config):\n try:\n # Initialize Web3 with RPC URL\n web3 = Web3(Web3.HTTPProvider(config[\"rpc_url\"]))\n\n # Prepare account\n account = web3.eth.account.from_key(config[\"private_key\"])\n\n # Load ABI\n abi = get_abi(\"Storage\")\n\n # Create contract instance\n contract = web3.eth.contract(address=config[\"contract_address\"], abi=abi)\n\n # Get initial value\n initial_value = contract.functions.storedNumber().call()\n print(\"Current stored value:\", initial_value)\n\n # Get current nonce\n nonce = web3.eth.get_transaction_count(account.address)\n\n # Prepare transaction\n transaction = contract.functions.setNumber(1).build_transaction(\n {\"from\": account.address, \"nonce\": nonce}\n )\n\n # Sign transaction\n signed_txn = web3.eth.account.sign_transaction(\n transaction, private_key=config[\"private_key\"]\n )\n\n # Send transaction\n tx_hash = web3.eth.send_raw_transaction(signed_txn.raw_transaction)\n print(f\"Transaction hash: {tx_hash.hex()}\")\n\n # Wait for receipt\n receipt = web3.eth.wait_for_transaction_receipt(tx_hash)\n\n # Get updated value\n new_value = contract.functions.storedNumber().call()\n print(\"New stored value:\", new_value)\n\n return receipt\n\n except Exception as error:\n print(\"Update failed:\", error)\n raise error\n\n\nif __name__ == \"__main__\":\n # Example usage\n import asyncio\n\n config = {\n \"rpc_url\": \"INSERT_RPC_URL\",\n \"private_key\": \"INSERT_PRIVATE_KEY\",\n \"contract_address\": \"INSERT_CONTRACT_ADDRESS\",\n }\n\n asyncio.run(update_storage(config))\n\n```\n\nBe sure to replace the `INSERT_RPC_URL`, `INSERT_PRIVATE_KEY`, and `INSERT_CONTRACT_ADDRESS` placeholders with your specific values.\n\nTo interact with the contract, run:\n\n```bash\npython update_storage.py\n```"} +{"page_id": "smart-contracts-libraries-web3-py", "page_title": "Web3.py", "index": 8, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 13693, "end_char": 14093, "estimated_token_count": 106, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- External __Web3.py Docs__\n\n ---\n\n Explore the Web3.py documentation to learn how to use additional features, such as wallet management, signing messages, subscribing to events, and more.\n\n [:octicons-arrow-right-24: Get Started](https://web3py.readthedocs.io/en/stable/){target=\\_blank}\n\n
"} {"page_id": "smart-contracts-overview", "page_title": "Smart Contracts Overview", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 35, "end_char": 710, "estimated_token_count": 103, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nPolkadot Hub provides a production-ready smart contract platform that combines Ethereum compatibility with the performance and cross-chain capabilities of the Polkadot ecosystem. Developers can deploy smart contracts directly on Polkadot Hub while using familiar Ethereum tooling, workflows, and programming languages.\n\nBuilt with a dual-VM approach, Polkadot Hub offers two execution backends: REVM for unmodified EVM compatibility and native PolkaVM for optimized computationally expensive workloads. This dual-VM architecture enables developers to migrate existing Ethereum contracts instantly or optimize for speed and efficiency with native execution."} {"page_id": "smart-contracts-overview", "page_title": "Smart Contracts Overview", "index": 1, "depth": 2, "title": "Why Build on Polkadot Hub", "anchor": "why-build-on-polkadot-hub", "start_char": 710, "end_char": 740, "estimated_token_count": 7, "token_estimator": "heuristic-v1", "text": "## Why Build on Polkadot Hub"} {"page_id": "smart-contracts-overview", "page_title": "Smart Contracts Overview", "index": 2, "depth": 3, "title": "Ethereum Compatibility", "anchor": "ethereum-compatibility", "start_char": 740, "end_char": 1300, "estimated_token_count": 114, "token_estimator": "heuristic-v1", "text": "### Ethereum Compatibility\n\nDeploy existing Ethereum contracts with zero modifications while maintaining full compatibility with your existing development stack:\n\n- **Complete JSON-RPC API support**: Use MetaMask, Hardhat, Remix, Foundry, and all standard Ethereum tooling.\n- **Standard libraries**: Integrate Ethers.js, Web3.js, Viem, Wagmi, and Web3.py without changes.\n- **Solidity development**: Write contracts in Solidity or migrate existing code directly.\n- **Familiar workflows**: Maintain your existing deployment, testing, and monitoring processes."} diff --git a/llms.txt b/llms.txt index 8efaec4b5..83edd2853 100644 --- a/llms.txt +++ b/llms.txt @@ -6,7 +6,7 @@ This directory lists URLs for raw Markdown pages that complement the rendered pages on the documentation site. Use these Markdown files to retain semantic context when prompting models while avoiding passing HTML elements. ## Metadata -- Documentation pages: 127 +- Documentation pages: 125 - Categories: 13 ## Docs @@ -219,8 +219,6 @@ Docs: Polkadot Hub Docs: Uncategorized - [AI Ready Docs](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-ai-ready-docs.md): Download LLM-optimized files of the Polkadot documentation, including full content and category-specific resources for AI agents. -- [Subscribe to Updates](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-explore-resources.md): Find Polkadot developer resources, tutorials, forums, governance proposals, and community platforms like StackExchange, Reddit, and YouTube. -- [Get in Touch](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-get-in-touch.md): Developer support for Polkadot via Telegram, Matrix, and Discord. Get help with parachains, smart contracts, nodes, and ecosystem tools. - [Support](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support.md): Start here to get developer support for Polkadot. Connect with the team, find help, and explore resources beyond the documentation. - [Polkadot Developer Docs](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/index.md): Explore everything you need to start building on top of Polkadot, a protocol that provides parachains with shared security and interoperability using XCM. - [reference-tools-chopsticks](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-chopsticks.md): No description available. diff --git a/smart-contracts/connect.md b/smart-contracts/connect.md index 1ad1edcfa..ffe137e16 100644 --- a/smart-contracts/connect.md +++ b/smart-contracts/connect.md @@ -40,7 +40,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t Chain ID ```text - 420420422 + 420420417 ``` --- @@ -48,7 +48,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t RPC URL ```text - https://testnet-passet-hub-eth-rpc.polkadot.io + https://services.polkadothub-rpc.com/testnet ``` --- @@ -56,7 +56,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t Block explorer URL ```text - https://blockscout-passet-hub.parity-testnet.parity.io/ + https://polkadot.testnet.routescan.io/ ``` @@ -64,7 +64,7 @@ Developers can leverage smart contracts across diverse networks, from TestNets t You will need testnet tokens to perform transactions and engage with smart contracts on any chain. Here's how to obtain Paseo (PAS) tokens for testing purposes: -1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank}. If the desired network is not already selected, choose it from the Network drop-down. +1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank}. If the desired network is not already selected, choose it from the Network drop-down. 2. Copy your address linked to the TestNet and paste it into the designated field. diff --git a/smart-contracts/cookbook/dapps/zero-to-hero.md b/smart-contracts/cookbook/dapps/zero-to-hero.md index 459733785..cae805b85 100644 --- a/smart-contracts/cookbook/dapps/zero-to-hero.md +++ b/smart-contracts/cookbook/dapps/zero-to-hero.md @@ -165,7 +165,7 @@ const config: HardhatUserConfig = { polkadotTestNet: { type: "http", chainType: "l1", - url: 'http://127.0.0.1:8545', + url: 'https://services.polkadothub-rpc.com/testnet', accounts: [process.env.PRIVATE_KEY || ''], }, }, @@ -222,7 +222,7 @@ You should see output similar to: npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet WARNING: You are using Node.js 23.11.0 which is not supported by Hardhat. Please upgrade to 22.10.0 or a later LTS version (even major version number) - βœ” Confirm deploy to network polkadotTestNet (420420420)? … yes + βœ” Confirm deploy to network polkadotTestNet (420420417)? … yes Hardhat Ignition πŸš€ Deploying [ StorageModule ] Batch #1 @@ -267,7 +267,7 @@ To interact with Polkadot Hub, you need to set up a [Public Client](https://viem import { createPublicClient, http, createWalletClient, custom } from 'viem' import 'viem/window'; -const transport = http('http://127.0.0.1:8545') // TODO: change to the paseo asset hub RPC URL when it's available +const transport = http('https://services.polkadothub-rpc.com/testnet') // Configure the Polkadot Testnet Hub chain export const polkadotTestnet = { @@ -281,7 +281,7 @@ export const polkadotTestnet = { }, rpcUrls: { default: { - http: ['http://127.0.0.1:8545'], // TODO: change to the paseo asset hub RPC URL + http: ['https://services.polkadothub-rpc.com/testnet'], }, }, } as const diff --git a/smart-contracts/dev-environments/hardhat.md b/smart-contracts/dev-environments/hardhat.md index 70353bfb7..9fd81d016 100644 --- a/smart-contracts/dev-environments/hardhat.md +++ b/smart-contracts/dev-environments/hardhat.md @@ -82,14 +82,14 @@ To use Hardhat with Polkadot Hub, define the network configuration in your `hard import { vars } from 'hardhat/config'; const config: HardhatUserConfig = { - solidity: '0.8.28', - networks: { + solidity: '0.8.28', + networks: { polkadotTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, - accounts: [vars.get('PRIVATE_KEY')], + url: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, + accounts: [vars.get('PRIVATE_KEY')], }, - }, + }, }; export default config; diff --git a/smart-contracts/explorers.md b/smart-contracts/explorers.md index 5514c9be5..879fe5674 100644 --- a/smart-contracts/explorers.md +++ b/smart-contracts/explorers.md @@ -33,18 +33,17 @@ Subscan is the flagship Polkadot ecosystem block explorer with comprehensive sup ![](/images/smart-contracts/explorers/block-explorers-1.webp) --> -### BlockScout + - diff --git a/smart-contracts/faucet.md b/smart-contracts/faucet.md index 39e70f6d2..c9c3bfbf8 100644 --- a/smart-contracts/faucet.md +++ b/smart-contracts/faucet.md @@ -19,13 +19,13 @@ Polkadot has a faucet that distributes free TestNet tokens to developers for tes ## Get Test Tokens -For Polkadot Hub TestNet, you can use the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank} to obtain test tokens. Here's how to do it: +For Polkadot Hub TestNet, you can use the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank} to obtain test tokens. Here's how to do it: -1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank}. If the desired network is not already selected, choose it from the **Network** drop-down. This example uses the Polkadot Hub TestNet. +1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank}. If the desired network is not already selected, choose it from the **Network** drop-down. This example uses the Polkadot Hub TestNet. 2. Copy your address linked to the TestNet and paste it into the designated field. 3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly. -![Polkadot Faucet](/images/smart-contracts/faucet/faucet-1.gif) +![Polkadot Faucet](/images/smart-contracts/faucet/faucet-01.gif) ## Things to Consider diff --git a/smart-contracts/for-eth-devs/json-rpc-apis.md b/smart-contracts/for-eth-devs/json-rpc-apis.md index 180787e39..f38a34a5d 100644 --- a/smart-contracts/for-eth-devs/json-rpc-apis.md +++ b/smart-contracts/for-eth-devs/json-rpc-apis.md @@ -13,7 +13,7 @@ Polkadot Hub provides Ethereum compatibility through its JSON-RPC interface, all This guide uses the Polkadot Hub TestNet endpoint: ```text -https://testnet-passet-hub-eth-rpc.polkadot.io +https://services.polkadothub-rpc.com/testnet ``` ## Available Methods @@ -29,7 +29,7 @@ None. **Example**: ```bash title="eth_accounts" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -52,7 +52,7 @@ None. **Example**: ```bash title="eth_blockNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -82,7 +82,7 @@ Executes a new message call immediately without creating a transaction. [Referen **Example**: ```bash title="eth_call" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -110,7 +110,7 @@ None. **Example**: ```bash title="eth_chainId" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -140,7 +140,7 @@ Estimates gas required for a transaction. [Reference](https://ethereum.org/devel **Example**: ```bash title="eth_estimateGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -168,7 +168,7 @@ None. **Example**: ```bash title="eth_gasPrice" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -192,7 +192,7 @@ Returns the balance of a given address. [Reference](https://ethereum.org/develop **Example**: ```bash title="eth_getBalance" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -218,7 +218,7 @@ Returns information about a block by its hash. [Reference](https://ethereum.org/ **Example**: ```bash title="eth_getBlockByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -244,7 +244,7 @@ Returns information about a block by its number. [Reference](https://ethereum.or **Example**: ```bash title="eth_getBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -269,7 +269,7 @@ Returns the number of transactions in a block from a block number. [Reference](h **Example**: ```bash title="eth_getBlockTransactionCountByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -294,7 +294,7 @@ Returns the number of transactions in a block from a block hash. [Reference](htt **Example**: ```bash title="eth_getBlockTransactionCountByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -320,7 +320,7 @@ Returns the code at a given address. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_getCode" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -350,7 +350,7 @@ Returns an array of all logs matching a given filter object. [Reference](https:/ **Example**: ```bash title="eth_getLogs" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -378,7 +378,7 @@ Returns the value from a storage position at a given address. [Reference](https: **Example**: ```bash title="eth_getStorageAt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -404,7 +404,7 @@ Returns the number of transactions sent from an address (nonce). [Reference](htt **Example**: ```bash title="eth_getTransactionCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -429,7 +429,7 @@ Returns information about a transaction by its hash. [Reference](https://ethereu **Example**: ```bash title="eth_getTransactionByHash" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -455,7 +455,7 @@ Returns information about a transaction by block number and transaction index. [ **Example**: ```bash title="eth_getTransactionByBlockNumberAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -481,7 +481,7 @@ Returns information about a transaction by block hash and transaction index. [Re **Example**: ```bash title="eth_getTransactionByBlockHashAndIndex" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -506,7 +506,7 @@ Returns the receipt of a transaction by transaction hash. [Reference](https://et **Example**: ```bash title="eth_getTransactionReceipt" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -531,7 +531,7 @@ None. **Example**: ```bash title="eth_maxPriorityFeePerGas" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -554,7 +554,7 @@ Submits a raw transaction. [Reference](https://ethereum.org/developers/docs/apis **Example**: ```bash title="eth_sendRawTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -586,7 +586,7 @@ Creates and sends a new transaction. [Reference](https://ethereum.org/developers **Example**: ```bash title="eth_sendTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -619,7 +619,7 @@ None. **Example**: ```bash title="eth_syncing" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -642,7 +642,7 @@ None. **Example**: ```bash title="net_listening" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -665,7 +665,7 @@ None. **Example**: ```bash title="net_peerCount" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -688,7 +688,7 @@ None. **Example**: ```bash title="net_version" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -711,7 +711,7 @@ None. **Example**: ```bash title="system_health" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -734,7 +734,7 @@ None. **Example**: ```bash title="web3_clientVersion" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -760,7 +760,7 @@ Traces a block's execution by its number and returns a detailed execution trace **Example**: ```bash title="debug_traceBlockByNumber" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -786,7 +786,7 @@ Traces the execution of a single transaction by its hash and returns a detailed **Example**: ```bash title="debug_traceTransaction" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", @@ -819,7 +819,7 @@ Executes a new message call and returns a detailed execution trace without creat **Example**: ```bash title="debug_traceCall" -curl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \ +curl -X POST https://services.polkadothub-rpc.com/testnet \ -H "Content-Type: application/json" \ --data '{ "jsonrpc":"2.0", diff --git a/smart-contracts/integrations/wallets.md b/smart-contracts/integrations/wallets.md index 7de3491fc..cced8884d 100644 --- a/smart-contracts/integrations/wallets.md +++ b/smart-contracts/integrations/wallets.md @@ -20,25 +20,29 @@ To get started with MetaMask, you need to install the [MetaMask extension](https For example, to connect to the Polkadot Hub TestNet via MetaMask, you need to follow these steps: -1. Open the MetaMask extension and click on the network icon to switch to the Polkadot Hub TestNet. +1. Open the MetaMask extension and click on the network dropdown to switch to the Polkadot Hub TestNet. ![](/images/smart-contracts/integrations/wallets/wallets-1.webp){: .browser-extension} -2. Click on the **Add a custom network** button. +2. Click on the **Custom** tab. ![](/images/smart-contracts/integrations/wallets/wallets-2.webp){: .browser-extension} -3. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\_blank} section for copy and paste parameters). +3. Click on the **Add a custom network** button. ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension} -4. Click on **Polkadot Hub TestNet** to switch the network. +4. Complete the necessary fields, then click the **Save** button (refer to the [Networks](/smart-contracts/connect/#networks-details){target=\_blank} section for copy and paste parameters). + + ![](/images/smart-contracts/integrations/wallets/wallets-3.webp){: .browser-extension} + +5. Click on **Polkadot Hub TestNet** to switch the network. ![](/images/smart-contracts/integrations/wallets/wallets-4.webp){: .browser-extension} The steps in the preceding section can be used to connect to any chain by modifying the network specification and endpoint parameters. -### SubWallet + ### Talisman @@ -81,37 +82,28 @@ To use Talisman with Polkadot Hub TestNet: 1. Install the [Talisman extension](https://talisman.xyz/download){target=\_blank} and set up your wallet by following the on-screen instructions. -2. Once installed, click on the Talisman icon in your browser extensions and click on the **Settings** button. +2. Once installed, click on the Talisman icon in your browser extensions and click on the **More** button. ![](/images/smart-contracts/integrations/wallets/wallets-5.webp){: .browser-extension} -3. Click the button **All settings**. +3. Click the button **Manage Networks**. ![](/images/smart-contracts/integrations/wallets/wallets-6.webp){: .browser-extension} -4. Go to the **Networks & Tokens** section. +4. Click on the **+ Add network** button. ![](/images/smart-contracts/integrations/wallets/wallets-7.webp) -5. Click the **Manage networks** button. +5. Fill in the form with the required parameters and click the ave** button. ![](/images/smart-contracts/integrations/wallets/wallets-8.webp) -6. Click the **+ Add network** button. +6. After that, you will see the **Polkadot Hub TestNet** in the list. ![](/images/smart-contracts/integrations/wallets/wallets-9.webp) -7. Fill in the form with the required parameters and click the **Add network** button. - - ![](/images/smart-contracts/integrations/wallets/wallets-10.webp) - -8. After that, you can switch to the Polkadot Hub TestNet by clicking on the network icon and selecting **Polkadot Hub TestNet**. - - ![](/images/smart-contracts/integrations/wallets/wallets-11.webp) - After selecting the network, Talisman will automatically configure the necessary RPC URL and chain ID for you. You can now use Talisman to interact with the Polkadot Hub TestNet. - ## Conclusion Choosing the right wallet for Polkadot Hub interactions depends on your specific requirements and familiarity with different interfaces. MetaMask provides a familiar entry point for developers with Ethereum experience, while Talisman offers deeper integration with Polkadot's unique features and native support for both EVM and Substrate accounts. By properly configuring your wallet connection, you gain access to the full spectrum of Polkadot Hub's capabilities. diff --git a/smart-contracts/libraries/ethers-js.md b/smart-contracts/libraries/ethers-js.md index 374e5f915..cfbc4a914 100644 --- a/smart-contracts/libraries/ethers-js.md +++ b/smart-contracts/libraries/ethers-js.md @@ -89,8 +89,8 @@ To interact with Polkadot Hub, you must set up an Ethers.js provider. This provi ```js const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet' }; ``` diff --git a/smart-contracts/libraries/web3-js.md b/smart-contracts/libraries/web3-js.md index 18f3ce166..c0fb2ce76 100644 --- a/smart-contracts/libraries/web3-js.md +++ b/smart-contracts/libraries/web3-js.md @@ -87,8 +87,8 @@ To interact with Polkadot Hub, you must set up a Web3.js provider. This provider ```js const PROVIDER_RPC = { - rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, + rpc: 'https://services.polkadothub-rpc.com/testnet', + chainId: 420420417, name: 'polkadot-hub-testnet' }; ``` diff --git a/smart-contracts/libraries/web3-py.md b/smart-contracts/libraries/web3-py.md index 655b487ed..2c3cec50f 100644 --- a/smart-contracts/libraries/web3-py.md +++ b/smart-contracts/libraries/web3-py.md @@ -48,7 +48,7 @@ To interact with Polkadot Hub, you must set up a Web3.py provider. This provider Replace `INSERT_RPC_URL` with the appropriate value. For instance, to connect to Polkadot Hub TestNet, use the following parameter: ```python - PROVIDER_RPC = 'https://testnet-passet-hub-eth-rpc.polkadot.io' + PROVIDER_RPC = 'https://services.polkadothub-rpc.com/testnet' ``` With the Web3 provider set up, start querying the blockchain. For instance, you can use the following code snippet to fetch the latest block number of the chain.