diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 0a30083..589d413 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -1,6 +1,8 @@ * General Guides ** xref:guides/weights_fees.adoc[Weights & Fees] ** xref:guides/async_backing.adoc[Async Backing] +* EVM Template Guides +** xref:guides/contract_migration.adoc[Contract Migration] * Runtimes ** xref:runtimes/generic.adoc[Generic Runtime] * Runtime Descriptions diff --git a/docs/modules/ROOT/pages/guides/contract_migration.adoc b/docs/modules/ROOT/pages/guides/contract_migration.adoc new file mode 100644 index 0000000..a353043 --- /dev/null +++ b/docs/modules/ROOT/pages/guides/contract_migration.adoc @@ -0,0 +1,47 @@ +:source-highlighter: highlight.js +:highlightjs-languages: rust +:github-icon: pass:[] + += Migrate a Contract from EVM chain + +This EVM template is powered by Frontier. It allows you to deploy almost any Solidity contract you have following these steps. + +== Step 1: Prepare and run the chain + +This step is basic, you can use our xref:index.adoc[guide for generic template]. It is recommended to use xref:guides/async_backing.adoc[async backing] for better experience. +The only additional thing that you will need to specify is the EVM Chain Id in your chainspec. For that, you need: + +* During the "Edit the chainspec" step execute one additional step: +** Edit the `evmChainId.chainId` to the value of your choice. Try to select a value that has no existing EVM chain assigned to it. + +== Step 2: Set up the development environment + +For Solidity development you can use link:https://book.getfoundry.sh/getting-started/installation[Foundry]. Feel free to use any other toolkit like ethers.js or web3.py. + +With the chain running, to start the development you need only two values: a private key from the account with some tokens on it and a url from EVM RPC. + + +=== Private Key. +If you have formed your own chainspec, you should have some keys ready. Alternatively, you can generate the key using any wallet of your choice (e.g. Metamask) and get some tokens to it. By default, we have these keys for prefunded accounts in the chainspec: + +* Private: `0x94834ac72c525a539097542a738816e8d2d18a60d6460c25e82b306441635dc4` + Public: `0x33c7c88f2B2Fcb83975fCDB08d2B5bf7eA29FDCE` +* Private: `0x3c959c97d3b687af91c27b93bbe8deb2bb2148f01bd48126ae757e202ab625a0` + Public: `0xc02db867898f227416BCB6d97190126A6b04988A` + +WARNING: You must not use these keys for any production purpose + +=== Url for the EVM RPC. + +This part is simple. You can use the same url that you would use with the polkadot.js wallet -- it serves the EVM JSON-RPC as well. If you have followed our guide, you can use http://localhost:8844. + +== Step 3: Deploy your contract + +Optional: If you want to test any contract, you can use our link:https://docs.openzeppelin.com/contracts/5.x/#foundry_git[guide about the standard contracts]. + +When you are ready with the contract just use `forge` that you have installed in a previous step: +``` +forge create --rpc-url --private-key +``` + +Output of this command will contain the contract address. That's it! \ No newline at end of file diff --git a/evm-template/Cargo.lock b/evm-template/Cargo.lock index 7085d52..f403103 100644 --- a/evm-template/Cargo.lock +++ b/evm-template/Cargo.lock @@ -7889,6 +7889,7 @@ dependencies = [ "frame-benchmarking", "frame-benchmarking-cli", "futures", + "hex-literal", "jsonrpsee", "log", "pallet-transaction-payment-rpc", diff --git a/evm-template/node/Cargo.toml b/evm-template/node/Cargo.toml index 844a425..b69d9cb 100644 --- a/evm-template/node/Cargo.toml +++ b/evm-template/node/Cargo.toml @@ -12,6 +12,7 @@ version = "0.1.2" [dependencies] clap = { workspace = true } futures = { workspace = true } +hex-literal = { workspace = true } jsonrpsee = { workspace = true, features = [ "server" ] } log = { workspace = true } parity-scale-codec = { workspace = true } diff --git a/evm-template/node/src/chain_spec.rs b/evm-template/node/src/chain_spec.rs index 82e2db8..02e54a8 100644 --- a/evm-template/node/src/chain_spec.rs +++ b/evm-template/node/src/chain_spec.rs @@ -1,4 +1,5 @@ use cumulus_primitives_core::ParaId; +use hex_literal::hex; use parachain_template_runtime::{ constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AuraId, Signature, }; @@ -106,6 +107,8 @@ pub fn development_config() -> ChainSpec { get_account_id_from_seed::("Dave//stash"), get_account_id_from_seed::("Eve//stash"), get_account_id_from_seed::("Ferdie//stash"), + AccountId::from(hex!("33c7c88f2B2Fcb83975fCDB08d2B5bf7eA29FDCE")), + AccountId::from(hex!("c02db867898f227416BCB6d97190126A6b04988A")), ], get_account_id_from_seed::("Alice"), 1000.into(),