From 29bf8082de7f50c3ca20410c56d20fbea59df337 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:28 +0500 Subject: [PATCH 001/837] New translations intro.md (French) --- docs_fr/intro.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs_fr/intro.md diff --git a/docs_fr/intro.md b/docs_fr/intro.md new file mode 100644 index 0000000000..fef3e43fb8 --- /dev/null +++ b/docs_fr/intro.md @@ -0,0 +1,52 @@ +--- +title: Core DAO - Decentralized applications secured by Bitcoin +sidebar_position: 1 +--- + +# Core DAO - Decentralized Applications Secured by Bitcoin + +## 👨‍💻 Getting Started + +Core Chain is the first Bitcoin-aligned EVM-compatible Layer-1 blockchain, designed to be Bitcoin's complementary and hyper-scalable smart contract platform. With over **50%** of Bitcoin mining hash power and over **4,800** in count and more than **$313 Million** worth Bitcoin staked are already contributing to its security model and through the ground-breaking innovation of Non-Custodial Bitcoin staking, Core Chain is unlocking Bitcoin both as the prime protector and central asset of the future of DeFi. + +![core-header](../static/img/core-header.png) + +New to Core Chain? Let's discover **Core Chain in less than 5 minutes**. + +## 📔 Learn about Core Chain + +Dive into what Core Chain is and start your Web3 journey with Core. +\* [An overview about Core Chain](./Learn/introduction/what-is-core-chain.md) +\* [Read about the core concepts of Core Chain](category/core-concepts) +\* [Understand the Underlying Architecture](./Learn/core-concepts/architecture.md) + +## 👓 Explore the Core Chain + +Get Familiar with the Core Chain Ecosystem +\* [Explore Why Core Chain is the Right Choice](./Learn/introduction/why-core-chain.md) +\* [Explore the Different Products by Core Chain](category/products) +\* [See Whats Being Build on the Core Chain](https://coredao.org/explore/ecosystem) + +## 🔌 Run a Node on Core Chain + +Participate in the Core Chain network by running different types of Nodes +\* [Run a Full Node on the Core Chain Network](./Node/Full-Node/on-mainnet.md) +\* [Run a Validator Node on the Core Chain Network](./Node/config/validator-node-config.md) +\* [Run a RPC Node on the Core Chain Network](./Node/config/rpc-node-config.md) +\* [Run an Archive Node on the Core Chain Network](./Node/config/archive-node-config.md) +\* [Run a Snapshot Node on the Core Chain Network](./Node/config/snapshot-node-config.md) + +## 👨‍🔧 Building on Core Chain + +Starting building on the Core Chain and Contribute to the BTC DeFi Landscape +\* [Explore the Developer Tooling Landscape](./Dev-Guide/dev-tools.md) +\* [Configure your Wallets with Core Network](./Dev-Guide/core-testnet-wallet-config.md) +\* [Fund your wallets with tCORE](./Dev-Guide/core-faucet.md) +\* [Iterate through Hands-on Detailed Guides to Jumpstart your Journey on Core](category/dev-guides) +\* [Build a Full-Stack dApp on Core Chain](./Dev-Guide/dapp-on-core.md) + +## 🙋‍♀️ Help & Support + +Connect with Core Team for any help or support required +\* [Official Discord Server for Help & Support](https://discord.com/invite/coredaoofficial) +\* [Official Telegram Developer Channel for technical support](https://t.me/CoreDAOTelegram) From cb7065d70ddc3aac3bb4a3c9a768f77e964280c2 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:29 +0500 Subject: [PATCH 002/837] New translations intro.md (Spanish) --- docs_es/intro.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs_es/intro.md diff --git a/docs_es/intro.md b/docs_es/intro.md new file mode 100644 index 0000000000..fef3e43fb8 --- /dev/null +++ b/docs_es/intro.md @@ -0,0 +1,52 @@ +--- +title: Core DAO - Decentralized applications secured by Bitcoin +sidebar_position: 1 +--- + +# Core DAO - Decentralized Applications Secured by Bitcoin + +## 👨‍💻 Getting Started + +Core Chain is the first Bitcoin-aligned EVM-compatible Layer-1 blockchain, designed to be Bitcoin's complementary and hyper-scalable smart contract platform. With over **50%** of Bitcoin mining hash power and over **4,800** in count and more than **$313 Million** worth Bitcoin staked are already contributing to its security model and through the ground-breaking innovation of Non-Custodial Bitcoin staking, Core Chain is unlocking Bitcoin both as the prime protector and central asset of the future of DeFi. + +![core-header](../static/img/core-header.png) + +New to Core Chain? Let's discover **Core Chain in less than 5 minutes**. + +## 📔 Learn about Core Chain + +Dive into what Core Chain is and start your Web3 journey with Core. +\* [An overview about Core Chain](./Learn/introduction/what-is-core-chain.md) +\* [Read about the core concepts of Core Chain](category/core-concepts) +\* [Understand the Underlying Architecture](./Learn/core-concepts/architecture.md) + +## 👓 Explore the Core Chain + +Get Familiar with the Core Chain Ecosystem +\* [Explore Why Core Chain is the Right Choice](./Learn/introduction/why-core-chain.md) +\* [Explore the Different Products by Core Chain](category/products) +\* [See Whats Being Build on the Core Chain](https://coredao.org/explore/ecosystem) + +## 🔌 Run a Node on Core Chain + +Participate in the Core Chain network by running different types of Nodes +\* [Run a Full Node on the Core Chain Network](./Node/Full-Node/on-mainnet.md) +\* [Run a Validator Node on the Core Chain Network](./Node/config/validator-node-config.md) +\* [Run a RPC Node on the Core Chain Network](./Node/config/rpc-node-config.md) +\* [Run an Archive Node on the Core Chain Network](./Node/config/archive-node-config.md) +\* [Run a Snapshot Node on the Core Chain Network](./Node/config/snapshot-node-config.md) + +## 👨‍🔧 Building on Core Chain + +Starting building on the Core Chain and Contribute to the BTC DeFi Landscape +\* [Explore the Developer Tooling Landscape](./Dev-Guide/dev-tools.md) +\* [Configure your Wallets with Core Network](./Dev-Guide/core-testnet-wallet-config.md) +\* [Fund your wallets with tCORE](./Dev-Guide/core-faucet.md) +\* [Iterate through Hands-on Detailed Guides to Jumpstart your Journey on Core](category/dev-guides) +\* [Build a Full-Stack dApp on Core Chain](./Dev-Guide/dapp-on-core.md) + +## 🙋‍♀️ Help & Support + +Connect with Core Team for any help or support required +\* [Official Discord Server for Help & Support](https://discord.com/invite/coredaoofficial) +\* [Official Telegram Developer Channel for technical support](https://t.me/CoreDAOTelegram) From 699121eaa019d8c2aa9f5b7b7381cb460fbecb63 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:30 +0500 Subject: [PATCH 003/837] New translations bridge-with-layerzero.md (French) --- docs_fr/Dev-Guide/bridge-with-layerzero.md | 163 +++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 docs_fr/Dev-Guide/bridge-with-layerzero.md diff --git a/docs_fr/Dev-Guide/bridge-with-layerzero.md b/docs_fr/Dev-Guide/bridge-with-layerzero.md new file mode 100644 index 0000000000..c38c13cc51 --- /dev/null +++ b/docs_fr/Dev-Guide/bridge-with-layerzero.md @@ -0,0 +1,163 @@ +--- +sidebar_label: Bridging Tokens to Core With LayerZero +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Bridging Tokens to Core With LayerZero + +--- + +This guide outlines the steps to bridge your ERC-20 token to Core using Omnichain Fungible Tokens (OFT) via LayerZero. LayerZero's protocol enables seamless cross-chain communications, allowing your token to operate across multiple chains. Please refer to LayerZero for all the[ supported source blockchains](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids). + +## Overview + +Before proceeding, you should be aware of what omnichain fungible tokens and the LayerZero protocol are. + +**Omnichain Fungible Token (OFT)**: Enables the creation of tokens native to multiple chains, simplifying token management and enhancing interoperability. + +**LayerZero Protocol**: Serves as foundational technology for cross-chain interactions, providing a reliable method for different blockchains to communicate, ensuring secure and efficient transactions. + +## Bridging Existing ERC-20 Tokens to Core + +### Deploy LayerZero ProxyOFTV2 Contract on the Source Chain + +First, **access the ProxyOFTV2 contract** by retrieving the `ProxyOFTV2` contract code from the[ official repository](https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/ProxyOFTV2.sol). + +Then\*\*, adjust the ProxyOFTV2 contract for the source blockchain\*\*, like this: + +``` +constructor( + address _token, + uint8 _sharedDecimals, + address _lzEndpoint +``` + +Here's some context on what's present in this code snippet: + +- **Token Contract Address** (`_token`): Provide the ERC-20 token contract address for a contract that's already been deployed on the source chain. If your token was USDC on Ethereum, for example, you’d use contract address [0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48](https://etherscan.io/address/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) +- **Shared Decimals** (`_sharedDecimals`): Set the number of decimal places for the token in the LayerZero environment. The shared decimals normalize the differences between data type across EVM and non-EVM chains. It is a good practice to use a smaller shared decimal point on all chains so that your token can have a larger balance. + - If your token is deployed on non-EVM chains, it should be set as the lowest decimals across all chains. + - If your tokens are only deployed on EVM chains and all have decimals larger than eight, this value should be set as `8`. + - Please refer to this[ LayerZero doc](https://layerzero.gitbook.io/docs/evm-guides/layerzero-omnichain-contracts/oft/oftv2#what-should-i-set-as-shared-decimals) for more info. +- **LayerZero Endpoint Address for Source Chain** (`_lzEndpoint`): This endpoint address is required for the contract to interact with the LayerZero protocol. For example, Ethereum endpoint: 0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675. +- Please refer to the[ LayerZero documentation](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids) for the endpoints for supported blockchains. + +Finally, **deploy the `ProxyOFTV2` contract** to the chosen source blockchain. + +### Deploy LayerZero OFTV2 Contract on Core Chain + +First, **access the OFTV2 contract** by retrieving the `ProxyOFTV2` contract code from the[ official repository](https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/OFTV2.sol). + +\ +Then, **prepare parameters for OFTV2 Contract deployment on Core Chain**, like so: + +``` +constructor( + string memory _name, + string memory _symbol, + uint8 _sharedDecimals, + address _lzEndpoint +``` + +Here's some context on what's happening in this code snippet: + +- **Token Name** (`_name`): Specify your token name (e.g. USD Coin) +- **Token Symbol** (`_symbol`): Specify your token symbol (e.g. USDC) +- **Shared Decimals** (`_sharedDecimals`): Match the shared decimals in the `ProxyOFTV2` on the source chain. +- **LayerZero Endpoint Address for Core Chain** (`_lzEndpoint`): The endpoint address for Core Chain is `0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4`. +- Please refer to the[ LayerZero documentation](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids) for endpoints of the supported blockchains. + +Finally, **deploy the Contract on CoreDAO:** deploy this OFTV2 contract to the Core blockchain. + +### Linking Contracts via Trusted Remotes + +The term "trusted remote" comes from EVM-to-EVM messaging, and refers to the 40 bytes that identify the contract from which you will receive messages in your LayerZero User Application contract. The 40 bytes object is the packed bytes of the `remoteAddress` and the `localAddress`. + +You can generate `TrustedRemote` using `ethers.js`: + +``` +// the trusted remote (or sometimes referred to as the path or pathData) +// is the packed 40 bytes object of the REMOTE + LOCAL user application contract addresses + +let trustedRemote = hre.ethers.utils.solidityPack( + ['address','address'], + [remoteContract.address, localContract.address] +) +``` + +On the source blockchain, call the `ProxyOFTV2` contract's `setTrustedRemoteAddress` function with the following parameters: + +- `trustedRemote`: This is the 40 bytes generated by trusted remote in the previous step +- `localContract`: This is the source chain’s `ProxyOFTV2` contract address. +- `remoteContract`: This is the Core chain’s `OFTV2` contract address + +On the Core blockchain, call the `OFTV2` contract's `setTrustedRemoteAddress` function with the following parameters: + +- `trustedRemote`: This is the 40 bytes generated by trusted remote in the previous step. +- `localContract`: This is the Core chain’s `OFTV2` contract address. +- `remoteContract`: This is the source chain’s `ProxyOFTV2` contract address + +For more info, please refer to the[ LayerZero guide for setting trusted remotes](https://layerzero.gitbook.io/docs/evm-guides/master/set-trusted-remotes) to link your contracts across the two networks. + +### Set Minimum Gas Limit for Each Chain + +You'll need to set the minimum gas limit for each chain. It's advisable to use a 200k minimum for all EVM chains; the only major exception is Arbitrum, where the gas limit should be 2M. Here are the steps. + +First, call `setMinDstGas` on the source chain (Core’s[ chainId is 153](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids)). Be sure to include the packet type ("0" means send, "1" means send and call) and the gas limit amount. + +Then, call `setMinDstGas` on Core Chain with the[ chainId of the source chain](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids). Be sure to include the packet type ("0" meaning send, "1" meaning send and call) and the gas limit amount. + +Finally, make sure that your `AdapterParams` gas limit is greater than `setMinDstGas`. + +For more info, please refer to the[ LayerZero guide](https://layerzero.gitbook.io/docs/evm-guides/layerzero-omnichain-contracts/oft/oftv2). + +### Transfer Tokens Cross-Chain + +Here, we'll cover the basic steps involved in transferring tokens across chains. + +First, ensure that you have [Node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/) installed. + +Then, clone the `oft-transfer-script` repository found [here](https://github.com/LayerZero-Labs/oft-transfer-script/tree/main). + +With that done, navigate to the `hardhat` folder in the cloned repository and run `npm install` to install the required npm packages. + +Next, create an `.env` file in the root directory of the repository and add the following variables: + +- `RPC_ENDPOINT`: This should be the URL of your Ethereum JSON RPC endpoint. +- `PRIVATE_KEY`: The private key of the Ethereum address you intend to use with the script. + +Here's a code snippet explaining how the `RPC_ENDPOINT` and `PRIVATE_KEY` should be configured: + +``` +RPC_ENDPOINT= +PRIVATE_KEY= +``` + +Finally, run the FT Token Transfer script. This script is designed to interact with the OFT smart contract to facilitate token transfers using `estimateFees()` and `sendFrom()`. Here's a little more context on what these methods accomplish: + +- `estimateFees()`: This function provides an estimate of the fees required to send a certain amount of tokens. +- `sendFrom()`: This function allows you to send tokens from one address on the source blockchain to another on the destination. + +Here's a code snippet showing how to transfer tokens with `sendFrom`: + +``` +npx hardhat sendFrom --qty 100000000000000 --network core +``` + +### Manual Transfers via Etherscan + +If your `ProxyOFT` contract is registered on Etherscan, you can use the Etherscan user interface to transfer your ERC20 tokens manually by calling the `sendFrom()` function with the following parameters: + +- `from`: This is the sender’s address on Ethereum. +- `dstChainId`: LayerZero’s unique chain ID for the receiving chain (we’ll use [chainId 153](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids) for Core chain). +- `toAddress`: The intended recipient’s address on Core chain. +- `amount`: The number of tokens **in wei units.** +- `refundAddress`: This is the address where gas refunds will be sent if necessary. It's wise to use the sender’s address as the refund address. +- `zroAddress`: On Etherscan, the "zero address" is `0x0000000000000000000000000000000000000000`. +- `adapterParams`: 0x +- `nativeFee`: you can calculate the native fee by calling the `estimateSendFee` function on the same contract using the same `remoteChainId`, `toAddress`, `amount`, `useZro`, and `adapterParams` above. + +## LayerZero Integration Checklist + +Please refer to the[ checklist](https://layerzero.gitbook.io/docs/evm-guides/layerzero-integration-checklist) to prepare for a Mainnet deployment. From f6c274cd51bc079089e7e72f4564ae899993acc0 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:32 +0500 Subject: [PATCH 004/837] New translations bridge-with-layerzero.md (Spanish) --- docs_es/Dev-Guide/bridge-with-layerzero.md | 163 +++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 docs_es/Dev-Guide/bridge-with-layerzero.md diff --git a/docs_es/Dev-Guide/bridge-with-layerzero.md b/docs_es/Dev-Guide/bridge-with-layerzero.md new file mode 100644 index 0000000000..c38c13cc51 --- /dev/null +++ b/docs_es/Dev-Guide/bridge-with-layerzero.md @@ -0,0 +1,163 @@ +--- +sidebar_label: Bridging Tokens to Core With LayerZero +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Bridging Tokens to Core With LayerZero + +--- + +This guide outlines the steps to bridge your ERC-20 token to Core using Omnichain Fungible Tokens (OFT) via LayerZero. LayerZero's protocol enables seamless cross-chain communications, allowing your token to operate across multiple chains. Please refer to LayerZero for all the[ supported source blockchains](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids). + +## Overview + +Before proceeding, you should be aware of what omnichain fungible tokens and the LayerZero protocol are. + +**Omnichain Fungible Token (OFT)**: Enables the creation of tokens native to multiple chains, simplifying token management and enhancing interoperability. + +**LayerZero Protocol**: Serves as foundational technology for cross-chain interactions, providing a reliable method for different blockchains to communicate, ensuring secure and efficient transactions. + +## Bridging Existing ERC-20 Tokens to Core + +### Deploy LayerZero ProxyOFTV2 Contract on the Source Chain + +First, **access the ProxyOFTV2 contract** by retrieving the `ProxyOFTV2` contract code from the[ official repository](https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/ProxyOFTV2.sol). + +Then\*\*, adjust the ProxyOFTV2 contract for the source blockchain\*\*, like this: + +``` +constructor( + address _token, + uint8 _sharedDecimals, + address _lzEndpoint +``` + +Here's some context on what's present in this code snippet: + +- **Token Contract Address** (`_token`): Provide the ERC-20 token contract address for a contract that's already been deployed on the source chain. If your token was USDC on Ethereum, for example, you’d use contract address [0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48](https://etherscan.io/address/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) +- **Shared Decimals** (`_sharedDecimals`): Set the number of decimal places for the token in the LayerZero environment. The shared decimals normalize the differences between data type across EVM and non-EVM chains. It is a good practice to use a smaller shared decimal point on all chains so that your token can have a larger balance. + - If your token is deployed on non-EVM chains, it should be set as the lowest decimals across all chains. + - If your tokens are only deployed on EVM chains and all have decimals larger than eight, this value should be set as `8`. + - Please refer to this[ LayerZero doc](https://layerzero.gitbook.io/docs/evm-guides/layerzero-omnichain-contracts/oft/oftv2#what-should-i-set-as-shared-decimals) for more info. +- **LayerZero Endpoint Address for Source Chain** (`_lzEndpoint`): This endpoint address is required for the contract to interact with the LayerZero protocol. For example, Ethereum endpoint: 0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675. +- Please refer to the[ LayerZero documentation](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids) for the endpoints for supported blockchains. + +Finally, **deploy the `ProxyOFTV2` contract** to the chosen source blockchain. + +### Deploy LayerZero OFTV2 Contract on Core Chain + +First, **access the OFTV2 contract** by retrieving the `ProxyOFTV2` contract code from the[ official repository](https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/OFTV2.sol). + +\ +Then, **prepare parameters for OFTV2 Contract deployment on Core Chain**, like so: + +``` +constructor( + string memory _name, + string memory _symbol, + uint8 _sharedDecimals, + address _lzEndpoint +``` + +Here's some context on what's happening in this code snippet: + +- **Token Name** (`_name`): Specify your token name (e.g. USD Coin) +- **Token Symbol** (`_symbol`): Specify your token symbol (e.g. USDC) +- **Shared Decimals** (`_sharedDecimals`): Match the shared decimals in the `ProxyOFTV2` on the source chain. +- **LayerZero Endpoint Address for Core Chain** (`_lzEndpoint`): The endpoint address for Core Chain is `0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4`. +- Please refer to the[ LayerZero documentation](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids) for endpoints of the supported blockchains. + +Finally, **deploy the Contract on CoreDAO:** deploy this OFTV2 contract to the Core blockchain. + +### Linking Contracts via Trusted Remotes + +The term "trusted remote" comes from EVM-to-EVM messaging, and refers to the 40 bytes that identify the contract from which you will receive messages in your LayerZero User Application contract. The 40 bytes object is the packed bytes of the `remoteAddress` and the `localAddress`. + +You can generate `TrustedRemote` using `ethers.js`: + +``` +// the trusted remote (or sometimes referred to as the path or pathData) +// is the packed 40 bytes object of the REMOTE + LOCAL user application contract addresses + +let trustedRemote = hre.ethers.utils.solidityPack( + ['address','address'], + [remoteContract.address, localContract.address] +) +``` + +On the source blockchain, call the `ProxyOFTV2` contract's `setTrustedRemoteAddress` function with the following parameters: + +- `trustedRemote`: This is the 40 bytes generated by trusted remote in the previous step +- `localContract`: This is the source chain’s `ProxyOFTV2` contract address. +- `remoteContract`: This is the Core chain’s `OFTV2` contract address + +On the Core blockchain, call the `OFTV2` contract's `setTrustedRemoteAddress` function with the following parameters: + +- `trustedRemote`: This is the 40 bytes generated by trusted remote in the previous step. +- `localContract`: This is the Core chain’s `OFTV2` contract address. +- `remoteContract`: This is the source chain’s `ProxyOFTV2` contract address + +For more info, please refer to the[ LayerZero guide for setting trusted remotes](https://layerzero.gitbook.io/docs/evm-guides/master/set-trusted-remotes) to link your contracts across the two networks. + +### Set Minimum Gas Limit for Each Chain + +You'll need to set the minimum gas limit for each chain. It's advisable to use a 200k minimum for all EVM chains; the only major exception is Arbitrum, where the gas limit should be 2M. Here are the steps. + +First, call `setMinDstGas` on the source chain (Core’s[ chainId is 153](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids)). Be sure to include the packet type ("0" means send, "1" means send and call) and the gas limit amount. + +Then, call `setMinDstGas` on Core Chain with the[ chainId of the source chain](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids). Be sure to include the packet type ("0" meaning send, "1" meaning send and call) and the gas limit amount. + +Finally, make sure that your `AdapterParams` gas limit is greater than `setMinDstGas`. + +For more info, please refer to the[ LayerZero guide](https://layerzero.gitbook.io/docs/evm-guides/layerzero-omnichain-contracts/oft/oftv2). + +### Transfer Tokens Cross-Chain + +Here, we'll cover the basic steps involved in transferring tokens across chains. + +First, ensure that you have [Node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/) installed. + +Then, clone the `oft-transfer-script` repository found [here](https://github.com/LayerZero-Labs/oft-transfer-script/tree/main). + +With that done, navigate to the `hardhat` folder in the cloned repository and run `npm install` to install the required npm packages. + +Next, create an `.env` file in the root directory of the repository and add the following variables: + +- `RPC_ENDPOINT`: This should be the URL of your Ethereum JSON RPC endpoint. +- `PRIVATE_KEY`: The private key of the Ethereum address you intend to use with the script. + +Here's a code snippet explaining how the `RPC_ENDPOINT` and `PRIVATE_KEY` should be configured: + +``` +RPC_ENDPOINT= +PRIVATE_KEY= +``` + +Finally, run the FT Token Transfer script. This script is designed to interact with the OFT smart contract to facilitate token transfers using `estimateFees()` and `sendFrom()`. Here's a little more context on what these methods accomplish: + +- `estimateFees()`: This function provides an estimate of the fees required to send a certain amount of tokens. +- `sendFrom()`: This function allows you to send tokens from one address on the source blockchain to another on the destination. + +Here's a code snippet showing how to transfer tokens with `sendFrom`: + +``` +npx hardhat sendFrom --qty 100000000000000 --network core +``` + +### Manual Transfers via Etherscan + +If your `ProxyOFT` contract is registered on Etherscan, you can use the Etherscan user interface to transfer your ERC20 tokens manually by calling the `sendFrom()` function with the following parameters: + +- `from`: This is the sender’s address on Ethereum. +- `dstChainId`: LayerZero’s unique chain ID for the receiving chain (we’ll use [chainId 153](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids) for Core chain). +- `toAddress`: The intended recipient’s address on Core chain. +- `amount`: The number of tokens **in wei units.** +- `refundAddress`: This is the address where gas refunds will be sent if necessary. It's wise to use the sender’s address as the refund address. +- `zroAddress`: On Etherscan, the "zero address" is `0x0000000000000000000000000000000000000000`. +- `adapterParams`: 0x +- `nativeFee`: you can calculate the native fee by calling the `estimateSendFee` function on the same contract using the same `remoteChainId`, `toAddress`, `amount`, `useZro`, and `adapterParams` above. + +## LayerZero Integration Checklist + +Please refer to the[ checklist](https://layerzero.gitbook.io/docs/evm-guides/layerzero-integration-checklist) to prepare for a Mainnet deployment. From 1702dd829f0854f970d928cbc8fad54f31621179 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:33 +0500 Subject: [PATCH 005/837] New translations contract-verify.md (French) --- docs_fr/Dev-Guide/contract-verify.md | 145 +++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 docs_fr/Dev-Guide/contract-verify.md diff --git a/docs_fr/Dev-Guide/contract-verify.md b/docs_fr/Dev-Guide/contract-verify.md new file mode 100644 index 0000000000..2f79e90c27 --- /dev/null +++ b/docs_fr/Dev-Guide/contract-verify.md @@ -0,0 +1,145 @@ +--- +sidebar_label: Contract Verification +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Contract Verification + +--- + +In the interest of transparency, we recommend verifying all contracts on [Core Scan](https://scan.coredao.org/). Let’s check out a few of the common methods for verifying contracts, via the web, API, and Hardhat. + +:::note +Make sure that your smart contract follows the [Solidity Support Guidelines by Core Chain](./smart-contract-guidelines.md), to do so ensure that the `evmVersion` parameter is set to `paris` under the solidity compiler settings. +::: + +## Web Verification via Core Scan + +Web verification is the most commonly used smart contract verification strategy. After deploying your smart contract to Core, you can use its source code to verify it on Core Scan. + +1. Search for the contract by address on [Core Scan](https://scan.test.btcs.network). +2. After locating the contract, select the **Contract** tab and click **Verify and Publish**_._ + +![verify-core-scan](../../static/img/contract-verification/contract-verify-1.avif) + +3\. Fill in the required verification information on the page, specifically: + +- Contract address; +- Compiler type: for simple contracts, select the `Single File` compiler type. For more complex contracts, such as contracts with external imports, select the `Standard Json` compiler type; +- Compiler version; +- Open-source license type; + +![verify-core-scan](../../static/img/contract-verification/contract-verify-2.avif) + +4\. On the next page, fill in the contract's Solidity source code. + +If your contract has constructor parameters, we recommend adding them in the `Constructor Arguments` field, although it’s not mandatory. The constructor parameters should be formatted as ABI-encoded bytes. Remix and other tools can generate these for you. + +If you enabled optimization during contract compilation, select "Yes" for the `Optimization` field. + +![verify-contract](../../static/img/contract-verification/contract-verify-3.avif) + +5\. Click on **Verify and Publish** to finish the process. + +![verify-contract](../../static/img/contract-verification/contract-verify-4.avif) + +Now your verified contract on Core Scan should look like this: + +![verify-contract](../../static/img/contract-verification/contract-verify-5.avif) + +## API Verification + +You can find the guide to using the Core API to verify contracts [here](https://docs.coredao.org/docs/api/api-documents/contracts). Please note that to make API calls you must register on Core Scan and generate an API key. + +If you're familiar with the Etherscan API, you're in luck! The API calls on Core are 100% compatible with the Etherscan API. You just need to replace the API key and endpoint URL and everything should work properly. + +## HardHat Verification + +HardHat verification is the most convenient way for developers to verify smart contracts. For more information on Hardhat verification, refer to the official Hardhat verification guide located [here](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify). + +Please note that you’ll need to add Core networks as custom chains, as seen below in a sample HardHat config: + +```javascript +/** +* @type import('hardhat/config').HardhatUserConfig +*/ + + +const { PrivateKey } = require('./secret.json'); +require('@nomiclabs/hardhat-ethers'); +require("@nomiclabs/hardhat-waffle"); +require("@nomicfoundation/hardhat-verify"); + +module.exports = { + defaultNetwork: 'testnet', + + networks: { + hardhat: { + }, + testnet: { + url: 'https://rpc.test.btcs.network', + accounts: [PrivateKey], + chainId: 1115, + }, + mainnet: { + url: 'https://rpc.coredao.org', + accounts: [PrivateKey], + chainId: 1116, + }, + }, + etherscan: { + apiKey: { + testnet: "api key", + mainnet: "api key" + }, + customChains: [ + { + network: "testnet", + chainId: 1115, + urls: { + apiURL: "https://api.test.btcs.network/api", + browserURL: "https://scan.test.btcs.network/" + } + }, + { + network: "mainnet", + chainId: 1116, + urls: { + apiURL: "https://openapi.coredao.org/api", + browserURL: "https://scan.coredao.org/" + } + } + ] + }, + + solidity: { + compilers: [ + { + version: '0.8.9', + settings: { + optimizer: { + enabled: false, + runs: 200, + }, + }, + } + ], + }, + paths: { + sources: './contracts', + cache: './cache', + artifacts: './artifacts', + }, + mocha: { + timeout: 20000, + }, +}; + +``` + +## Known Limitations + +- Currently Core only supports solc compiler versions up to 0.8.19. +- Libraries are not supported using API verifications. +- If you run into issues verifying very large (1000+ lines) single file contracts, we recommend switching to `Standard JSON` format for verification. From f2235665e78cd62cfd51cfe07817fdde33a7c33f Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:34 +0500 Subject: [PATCH 006/837] New translations contract-verify.md (Spanish) --- docs_es/Dev-Guide/contract-verify.md | 145 +++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 docs_es/Dev-Guide/contract-verify.md diff --git a/docs_es/Dev-Guide/contract-verify.md b/docs_es/Dev-Guide/contract-verify.md new file mode 100644 index 0000000000..2f79e90c27 --- /dev/null +++ b/docs_es/Dev-Guide/contract-verify.md @@ -0,0 +1,145 @@ +--- +sidebar_label: Contract Verification +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Contract Verification + +--- + +In the interest of transparency, we recommend verifying all contracts on [Core Scan](https://scan.coredao.org/). Let’s check out a few of the common methods for verifying contracts, via the web, API, and Hardhat. + +:::note +Make sure that your smart contract follows the [Solidity Support Guidelines by Core Chain](./smart-contract-guidelines.md), to do so ensure that the `evmVersion` parameter is set to `paris` under the solidity compiler settings. +::: + +## Web Verification via Core Scan + +Web verification is the most commonly used smart contract verification strategy. After deploying your smart contract to Core, you can use its source code to verify it on Core Scan. + +1. Search for the contract by address on [Core Scan](https://scan.test.btcs.network). +2. After locating the contract, select the **Contract** tab and click **Verify and Publish**_._ + +![verify-core-scan](../../static/img/contract-verification/contract-verify-1.avif) + +3\. Fill in the required verification information on the page, specifically: + +- Contract address; +- Compiler type: for simple contracts, select the `Single File` compiler type. For more complex contracts, such as contracts with external imports, select the `Standard Json` compiler type; +- Compiler version; +- Open-source license type; + +![verify-core-scan](../../static/img/contract-verification/contract-verify-2.avif) + +4\. On the next page, fill in the contract's Solidity source code. + +If your contract has constructor parameters, we recommend adding them in the `Constructor Arguments` field, although it’s not mandatory. The constructor parameters should be formatted as ABI-encoded bytes. Remix and other tools can generate these for you. + +If you enabled optimization during contract compilation, select "Yes" for the `Optimization` field. + +![verify-contract](../../static/img/contract-verification/contract-verify-3.avif) + +5\. Click on **Verify and Publish** to finish the process. + +![verify-contract](../../static/img/contract-verification/contract-verify-4.avif) + +Now your verified contract on Core Scan should look like this: + +![verify-contract](../../static/img/contract-verification/contract-verify-5.avif) + +## API Verification + +You can find the guide to using the Core API to verify contracts [here](https://docs.coredao.org/docs/api/api-documents/contracts). Please note that to make API calls you must register on Core Scan and generate an API key. + +If you're familiar with the Etherscan API, you're in luck! The API calls on Core are 100% compatible with the Etherscan API. You just need to replace the API key and endpoint URL and everything should work properly. + +## HardHat Verification + +HardHat verification is the most convenient way for developers to verify smart contracts. For more information on Hardhat verification, refer to the official Hardhat verification guide located [here](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify). + +Please note that you’ll need to add Core networks as custom chains, as seen below in a sample HardHat config: + +```javascript +/** +* @type import('hardhat/config').HardhatUserConfig +*/ + + +const { PrivateKey } = require('./secret.json'); +require('@nomiclabs/hardhat-ethers'); +require("@nomiclabs/hardhat-waffle"); +require("@nomicfoundation/hardhat-verify"); + +module.exports = { + defaultNetwork: 'testnet', + + networks: { + hardhat: { + }, + testnet: { + url: 'https://rpc.test.btcs.network', + accounts: [PrivateKey], + chainId: 1115, + }, + mainnet: { + url: 'https://rpc.coredao.org', + accounts: [PrivateKey], + chainId: 1116, + }, + }, + etherscan: { + apiKey: { + testnet: "api key", + mainnet: "api key" + }, + customChains: [ + { + network: "testnet", + chainId: 1115, + urls: { + apiURL: "https://api.test.btcs.network/api", + browserURL: "https://scan.test.btcs.network/" + } + }, + { + network: "mainnet", + chainId: 1116, + urls: { + apiURL: "https://openapi.coredao.org/api", + browserURL: "https://scan.coredao.org/" + } + } + ] + }, + + solidity: { + compilers: [ + { + version: '0.8.9', + settings: { + optimizer: { + enabled: false, + runs: 200, + }, + }, + } + ], + }, + paths: { + sources: './contracts', + cache: './cache', + artifacts: './artifacts', + }, + mocha: { + timeout: 20000, + }, +}; + +``` + +## Known Limitations + +- Currently Core only supports solc compiler versions up to 0.8.19. +- Libraries are not supported using API verifications. +- If you run into issues verifying very large (1000+ lines) single file contracts, we recommend switching to `Standard JSON` format for verification. From a182bbe20cb5591d96c21a6387936fecdc7453bc Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:35 +0500 Subject: [PATCH 007/837] New translations core-bridge-resources.md (French) --- docs_fr/Dev-Guide/core-bridge-resources.md | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 docs_fr/Dev-Guide/core-bridge-resources.md diff --git a/docs_fr/Dev-Guide/core-bridge-resources.md b/docs_fr/Dev-Guide/core-bridge-resources.md new file mode 100644 index 0000000000..55320e4936 --- /dev/null +++ b/docs_fr/Dev-Guide/core-bridge-resources.md @@ -0,0 +1,80 @@ +--- +sidebar_label: Core Bridge Resources +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Core Bridge Resources + +--- + +The[ Core Bridge](https://bridge.coredao.org/) is powered by LayerZero, and enables seamless asset transfers between Core and the wider blockchain world. The Core Bridge consists of two parts: LayerZero contracts on Core that facilitate cross-chain transfers, and a set of bridge or token contracts deployed both on Core and each blockchain it’s connected to. The audited bridge codebase can be found[ here](https://github.com/LayerZero-Labs/wrapped-asset-bridge), and the full list of bridge token contract addresses can be found [here](./core-bridge-resources.md). + +### LayerZero + +| LayerZero contracts on Core | +| ------------------------------------------------------------------------------------------------- | +| [LayerZero Endpoint](https://scan.coredao.org/address/0x9740ff91f1985d8d2b71494ae1a2f723bb3ed9e4) | +| [UltraLightNodeV2](https://scan.coredao.org/address/0x66a71dcef29a0ffbdbe3c6a460a3b5bc225cd675) | +| [NonceContract](https://scan.coredao.org/address/0x2d61dcdd36f10b22176e0433b86f74567d529aaa) | +| [FPValidator](https://scan.coredao.org/address/0x3c2269811836af69497e5f486a85d7316753cf62) | +| [MPTValidatorV1](https://scan.coredao.org/address/0xb6319cc6c8c27a8f5daf0dd3df91ea35c4720dd7) | +| [TreasuryV2](https://scan.coredao.org/address/0x5b19bd330a84c049b62d5b0fc2ba120217a18c1c) | + +### Bridges and Tokens + +| CORE | Addresses | +| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| WrappedTokenBridge | https://scan.coredao.org/address/0xa4218e1f39da4aadac971066458db56e901bcbde | +| WETH | https://scan.coredao.org/address/0xeab3ac417c4d6df6b143346a46fee1b847b50296 | +| USDC | https://scan.coredao.org/address/0xa4151b2b3e269645181dccf2d426ce75fcbdeca9 | +| USDT | https://scan.coredao.org/address/0x900101d06a7426441ae63e9ab3b9b0f63be145f1 | +| WBTC | https://scan.coredao.org/address/0x5832f53d147b3d6Cd4578B9CBD62425C7ea9d0Bd | +| Bitcoin BEP2 (BTCB) | https://scan.coredao.org/address/0x7A6888c85eDBA8E38F6C7E0485212da602761C08 | +| WBNB | https://scan.coredao.org/address/0xdFBc618d3c48e553Cb197F42482A0795bef7fe28 | +| stCORE | https://scan.coredao.org/token/0xb3a8f0f0da9ffc65318aa39e55079796093029ad | + +| ETHEREUM | Addresses | +| ------------------- | ------------------------------------------------------------------------------------------------------- | +| OriginalTokenBridge | https://etherscan.io/address/0x52e75d318cfb31f9a2edfa2dfee26b161255b233 | +| WETH | https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 | +| USDC | https://etherscan.io/address/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 | +| USDT | https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7 | +| WBTC | https://etherscan.io/address/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599 | + +| BNB Smart Chain (BSC) | Addresses | +| ---------------------------------------- | ------------------------------------------------------------------------------------------------------ | +| OriginalTokenBridge | https://bscscan.com/address/0x52e75d318cfb31f9a2edfa2dfee26b161255b233 | +| USDC | https://bscscan.com/address/0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d | +| USDT | https://bscscan.com/address/0x55d398326f99059ff775485246999027b3197955 | +| BTCB | 0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c | +| WBNB | 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c | + +| Polygon | Addresses | +| ------------------- | ---------------------------------------------------------------------------------------------------------- | +| OriginalTokenBridge | https://polygonscan.com/address/0x52e75d318cfb31f9a2edfa2dfee26b161255b233 | +| USDC | https://polygonscan.com/address/0x2791bca1f2de4661ed88a30c99a7a9449aa84174 | +| USDT | https://polygonscan.com/address/0xc2132d05d31c914a87c6611c10748aeb04b58e8f | +| WBTC | https://polygonscan.com/address/0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6 | + +| BNB Smart Chain (BSC) | Addresses | +| ---------------------------------------- | ------------------------------------------ | +| Bridge | 0x29d096cD18C0dA7500295f082da73316d704031A | +| USDC | 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 | +| USDT | 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9 | +| WBTC | 0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f | + +| OPTIMISM | Addresses | +| -------- | ------------------------------------------ | +| Bridge | 0x29d096cD18C0dA7500295f082da73316d704031A | +| USDC | 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85 | +| USDT | 0x94b008aA00579c1307B0EF2c499aD98a8ce58e58 | +| WBTC | 0x68f180fcCe6836688e9084f035309E29Bf0A2095 | + +| AVALANCHE | Addresses | +| -------------------------------------------------------------------- | ------------------------------------------ | +| Bridge | 0x29d096cD18C0dA7500295f082da73316d704031A | +| Bitcoin Avalanche Bridged (BTC.b) | 0x2297aEbD383787A160DD0d9F71508148769342E3 | +| USDC | 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E | +| USDT | 0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7 | +| WBTC | 0x50b7545627a5162F82A992c33b87aDc75187B218 | From 94269d22b4242f226345aaaf93ea5e199238a0a5 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:37 +0500 Subject: [PATCH 008/837] New translations core-bridge-resources.md (Spanish) --- docs_es/Dev-Guide/core-bridge-resources.md | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 docs_es/Dev-Guide/core-bridge-resources.md diff --git a/docs_es/Dev-Guide/core-bridge-resources.md b/docs_es/Dev-Guide/core-bridge-resources.md new file mode 100644 index 0000000000..55320e4936 --- /dev/null +++ b/docs_es/Dev-Guide/core-bridge-resources.md @@ -0,0 +1,80 @@ +--- +sidebar_label: Core Bridge Resources +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Core Bridge Resources + +--- + +The[ Core Bridge](https://bridge.coredao.org/) is powered by LayerZero, and enables seamless asset transfers between Core and the wider blockchain world. The Core Bridge consists of two parts: LayerZero contracts on Core that facilitate cross-chain transfers, and a set of bridge or token contracts deployed both on Core and each blockchain it’s connected to. The audited bridge codebase can be found[ here](https://github.com/LayerZero-Labs/wrapped-asset-bridge), and the full list of bridge token contract addresses can be found [here](./core-bridge-resources.md). + +### LayerZero + +| LayerZero contracts on Core | +| ------------------------------------------------------------------------------------------------- | +| [LayerZero Endpoint](https://scan.coredao.org/address/0x9740ff91f1985d8d2b71494ae1a2f723bb3ed9e4) | +| [UltraLightNodeV2](https://scan.coredao.org/address/0x66a71dcef29a0ffbdbe3c6a460a3b5bc225cd675) | +| [NonceContract](https://scan.coredao.org/address/0x2d61dcdd36f10b22176e0433b86f74567d529aaa) | +| [FPValidator](https://scan.coredao.org/address/0x3c2269811836af69497e5f486a85d7316753cf62) | +| [MPTValidatorV1](https://scan.coredao.org/address/0xb6319cc6c8c27a8f5daf0dd3df91ea35c4720dd7) | +| [TreasuryV2](https://scan.coredao.org/address/0x5b19bd330a84c049b62d5b0fc2ba120217a18c1c) | + +### Bridges and Tokens + +| CORE | Addresses | +| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| WrappedTokenBridge | https://scan.coredao.org/address/0xa4218e1f39da4aadac971066458db56e901bcbde | +| WETH | https://scan.coredao.org/address/0xeab3ac417c4d6df6b143346a46fee1b847b50296 | +| USDC | https://scan.coredao.org/address/0xa4151b2b3e269645181dccf2d426ce75fcbdeca9 | +| USDT | https://scan.coredao.org/address/0x900101d06a7426441ae63e9ab3b9b0f63be145f1 | +| WBTC | https://scan.coredao.org/address/0x5832f53d147b3d6Cd4578B9CBD62425C7ea9d0Bd | +| Bitcoin BEP2 (BTCB) | https://scan.coredao.org/address/0x7A6888c85eDBA8E38F6C7E0485212da602761C08 | +| WBNB | https://scan.coredao.org/address/0xdFBc618d3c48e553Cb197F42482A0795bef7fe28 | +| stCORE | https://scan.coredao.org/token/0xb3a8f0f0da9ffc65318aa39e55079796093029ad | + +| ETHEREUM | Addresses | +| ------------------- | ------------------------------------------------------------------------------------------------------- | +| OriginalTokenBridge | https://etherscan.io/address/0x52e75d318cfb31f9a2edfa2dfee26b161255b233 | +| WETH | https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 | +| USDC | https://etherscan.io/address/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 | +| USDT | https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7 | +| WBTC | https://etherscan.io/address/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599 | + +| BNB Smart Chain (BSC) | Addresses | +| ---------------------------------------- | ------------------------------------------------------------------------------------------------------ | +| OriginalTokenBridge | https://bscscan.com/address/0x52e75d318cfb31f9a2edfa2dfee26b161255b233 | +| USDC | https://bscscan.com/address/0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d | +| USDT | https://bscscan.com/address/0x55d398326f99059ff775485246999027b3197955 | +| BTCB | 0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c | +| WBNB | 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c | + +| Polygon | Addresses | +| ------------------- | ---------------------------------------------------------------------------------------------------------- | +| OriginalTokenBridge | https://polygonscan.com/address/0x52e75d318cfb31f9a2edfa2dfee26b161255b233 | +| USDC | https://polygonscan.com/address/0x2791bca1f2de4661ed88a30c99a7a9449aa84174 | +| USDT | https://polygonscan.com/address/0xc2132d05d31c914a87c6611c10748aeb04b58e8f | +| WBTC | https://polygonscan.com/address/0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6 | + +| BNB Smart Chain (BSC) | Addresses | +| ---------------------------------------- | ------------------------------------------ | +| Bridge | 0x29d096cD18C0dA7500295f082da73316d704031A | +| USDC | 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 | +| USDT | 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9 | +| WBTC | 0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f | + +| OPTIMISM | Addresses | +| -------- | ------------------------------------------ | +| Bridge | 0x29d096cD18C0dA7500295f082da73316d704031A | +| USDC | 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85 | +| USDT | 0x94b008aA00579c1307B0EF2c499aD98a8ce58e58 | +| WBTC | 0x68f180fcCe6836688e9084f035309E29Bf0A2095 | + +| AVALANCHE | Addresses | +| -------------------------------------------------------------------- | ------------------------------------------ | +| Bridge | 0x29d096cD18C0dA7500295f082da73316d704031A | +| Bitcoin Avalanche Bridged (BTC.b) | 0x2297aEbD383787A160DD0d9F71508148769342E3 | +| USDC | 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E | +| USDT | 0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7 | +| WBTC | 0x50b7545627a5162F82A992c33b87aDc75187B218 | From e0b00fe3105add5ab28520c8f7799eaefd64ecb6 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:38 +0500 Subject: [PATCH 009/837] New translations core-explorer.md (French) --- docs_fr/Dev-Guide/core-explorer.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docs_fr/Dev-Guide/core-explorer.md diff --git a/docs_fr/Dev-Guide/core-explorer.md b/docs_fr/Dev-Guide/core-explorer.md new file mode 100644 index 0000000000..d5f3ba257d --- /dev/null +++ b/docs_fr/Dev-Guide/core-explorer.md @@ -0,0 +1,28 @@ +--- +sidebar_label: Core Explorer +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Core Scan Blockchain Explorer + +--- + +Core Explorer is a graphic user interface designed to allow users to interact with the CORE blockchain. Through this interface, a user can browse information about blocks that have been added to the blockchain, transactions that have occurred on the blockchain, wallet balances, and information about tCORE and CORE tokens. Core Network provides explorers for both its mainnet and testnet. + +### Explorers for Testnet + +- https://scan.test.btcs.network/ + +### Explorers for Mainnet + +- https://scan.coredao.org/ + +### Using the Explorer + +You can use the Testnet Core Scan blockchain explorer to find and review transactions. Copy your account's address from MetaMask and search for it on the explorer. In the picture below, we can see two transactions related to our account: + +- The one in which we fetched tCORE from Faucet; +- The one in which we sent tCORE to another address; + +![core-explorer](../../static/img/core-explorer.png) From b7baf5f5018a1077bc4a4d148cae7bfaa845fccf Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:39 +0500 Subject: [PATCH 010/837] New translations core-explorer.md (Spanish) --- docs_es/Dev-Guide/core-explorer.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docs_es/Dev-Guide/core-explorer.md diff --git a/docs_es/Dev-Guide/core-explorer.md b/docs_es/Dev-Guide/core-explorer.md new file mode 100644 index 0000000000..d5f3ba257d --- /dev/null +++ b/docs_es/Dev-Guide/core-explorer.md @@ -0,0 +1,28 @@ +--- +sidebar_label: Core Explorer +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Core Scan Blockchain Explorer + +--- + +Core Explorer is a graphic user interface designed to allow users to interact with the CORE blockchain. Through this interface, a user can browse information about blocks that have been added to the blockchain, transactions that have occurred on the blockchain, wallet balances, and information about tCORE and CORE tokens. Core Network provides explorers for both its mainnet and testnet. + +### Explorers for Testnet + +- https://scan.test.btcs.network/ + +### Explorers for Mainnet + +- https://scan.coredao.org/ + +### Using the Explorer + +You can use the Testnet Core Scan blockchain explorer to find and review transactions. Copy your account's address from MetaMask and search for it on the explorer. In the picture below, we can see two transactions related to our account: + +- The one in which we fetched tCORE from Faucet; +- The one in which we sent tCORE to another address; + +![core-explorer](../../static/img/core-explorer.png) From 513c4b6da68d3aabd1a95e4d1fdc8a53267afa63 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:40 +0500 Subject: [PATCH 011/837] New translations core-faucet.md (French) --- docs_fr/Dev-Guide/core-faucet.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs_fr/Dev-Guide/core-faucet.md diff --git a/docs_fr/Dev-Guide/core-faucet.md b/docs_fr/Dev-Guide/core-faucet.md new file mode 100644 index 0000000000..7c08bee7be --- /dev/null +++ b/docs_fr/Dev-Guide/core-faucet.md @@ -0,0 +1,27 @@ +--- +sidebar_label: Core Testnet Faucet +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Core Testnet Faucet + +--- + +To help users get started and allow developers to quickly prototype their dApps, Core has released the public [Core Testnet Faucet](https://scan.test.btcs.network/faucet) to distribute Core testnet tokens, **tCORE**. + +## Steps to Obtain tCORE from Core Testnet Faucet + +1. Navigate to the [faucet](https://scan.test.btcs.network/faucet) website. +2. Paste your address in the given textbox. Make sure you give the Core Testnet address of your wallet that you want to get funded with tCore. +3. Complete the CAPTCHA +4. Click the `Get tCORE` button. After requesting tCORE from the faucet, you'll see your MetaMask balance increase. + +![using-faucet](../../static/img/faucet/faucet.png) +:::caution +Each address can request **only one tCORE per day**. If you've run out of tCORE and the faucet won't send you more because of the one tCORE daily limit, come back tomorrow and try again! +::: + +:::note +tCORE is only used for testing and does not have any value. Do not use it for real financial transactions. +::: From ec55dc65e1930382384066ccc6981a44ac0ac717 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:41 +0500 Subject: [PATCH 012/837] New translations core-faucet.md (Spanish) --- docs_es/Dev-Guide/core-faucet.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs_es/Dev-Guide/core-faucet.md diff --git a/docs_es/Dev-Guide/core-faucet.md b/docs_es/Dev-Guide/core-faucet.md new file mode 100644 index 0000000000..7c08bee7be --- /dev/null +++ b/docs_es/Dev-Guide/core-faucet.md @@ -0,0 +1,27 @@ +--- +sidebar_label: Core Testnet Faucet +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Core Testnet Faucet + +--- + +To help users get started and allow developers to quickly prototype their dApps, Core has released the public [Core Testnet Faucet](https://scan.test.btcs.network/faucet) to distribute Core testnet tokens, **tCORE**. + +## Steps to Obtain tCORE from Core Testnet Faucet + +1. Navigate to the [faucet](https://scan.test.btcs.network/faucet) website. +2. Paste your address in the given textbox. Make sure you give the Core Testnet address of your wallet that you want to get funded with tCore. +3. Complete the CAPTCHA +4. Click the `Get tCORE` button. After requesting tCORE from the faucet, you'll see your MetaMask balance increase. + +![using-faucet](../../static/img/faucet/faucet.png) +:::caution +Each address can request **only one tCORE per day**. If you've run out of tCORE and the faucet won't send you more because of the one tCORE daily limit, come back tomorrow and try again! +::: + +:::note +tCORE is only used for testing and does not have any value. Do not use it for real financial transactions. +::: From 6673947435d6a902a364590b36ae1d31db543868 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:43 +0500 Subject: [PATCH 013/837] New translations core-mainnet-wallet-config.md (French) --- .../Dev-Guide/core-mainnet-wallet-config.md | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 docs_fr/Dev-Guide/core-mainnet-wallet-config.md diff --git a/docs_fr/Dev-Guide/core-mainnet-wallet-config.md b/docs_fr/Dev-Guide/core-mainnet-wallet-config.md new file mode 100644 index 0000000000..80705dca40 --- /dev/null +++ b/docs_fr/Dev-Guide/core-mainnet-wallet-config.md @@ -0,0 +1,117 @@ +--- +sidebar_label: Core Chain Mainnet +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Connect to Core Chain Mainnet + +--- + +:::note +This is a detailed guideline for connecting to Core Mainnet using the MetaMask wallet. +::: + +## Software Prequisites + +1. [MetaMask Wallet Browser Extension](https://metamask.io/) + +## MetaMask Wallet Setup + +We recommend using the [MetaMask web wallet](https://metamask.io/) to connect to Core Mainnet. You'll need to install MetaMask and set up your account before you can use it to connect to Core Mainnet. You can find MetaMask setup instructions here. + +## Adding Core Mainnet to MetaMask + +There are multiple ways to add Core Mainnet configurations to your MetaMask Wallet, we have listed the most trusted and testest ways below. + +### Adding Network Manually + +1. Click on the network selector button (the downward facing arrow next to the current network). This will display a list of networks to which you’re already connected. + +\mainnet-wallet-config-1 + +2. Click ‘Add network’ at the bottom of the network list + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-2.webp) + +3. A new browser tab will then open, displaying various fields to fill out: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-3.webp) + +Fill in the following network information and click `save` to add the network. + +- **Network Name:** Core Blockchain +- **New RPC URL:** https://rpc.ankr.com/core +- **Chain ID:** 1116 (**Note**: 0x45c is the same as 1116. The new version of MetaMask converts chain ID to hexadecimal format). +- **Currency Symbol:** CORE +- **Block Explorer URL:** https://scan.coredao.org + +4. After performing the above steps, you will be able to see the Core network the next time you access the network selector. + +### Adding the Core network via Chainlist.org + +1. Go to chainlist.org and search for ‘_Core_’ + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-4.webp) + +2. Double check to make sure to choose the right network. Please check the details in the below snapshots — Chain ID, Currency etc. to ensure you will add the correct one. + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-6.webp) + +3. Click the ‘_Add to MetaMask_’ button. + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-7.webp) + +4. Approve the action in your MetaMask by clicking the _‘Approve’_ button. + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-8.webp) + +The Core network is now added to your MetaMask. + +### Adding the Core network via the Core Explorer + +1. Go to https://scan.coredao.org/ and scroll all the way down on the page + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-9.webp) + +2. Click the ‘_Add Core Network_’ button + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-10.webp) + +3. Approve in your MetaMask + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-11.webp) + +4. After performing the above steps, you will be able to see Core network the next time you access the network selector. + +### Adding the Core network to MetaMask mobile wallet: + +1. Tap on the three lines in the top-left corner: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-12.webp) + +2. Select _‘Settings’_: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-13.webp) + +3. Select Networks: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-14.webp) + +4. Tap on ‘_Add Network_’: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-15.webp) + +5. Fill in the Custom RPC Network details and click _save_ to add the network. + +- **Network Name:** Core Blockchain +- **New RPC URL:** https://rpc.ankr.com/core +- **Chain ID:** 1116 (**Note**: 0x45c is the same as 1116. The new version of MetaMask converts chain ID to hexadecimal format). +- **Currency Symbol:** CORE +- **Block Explorer URL:** https://scan.coredao.org + +4. After performing the above steps, you will be able to see the Core network the next time you access the network selector. + +:::info +If you happen to have an error, or are struggling with adding the network please ask for help in the ‘support’ channel in the [Core Discord](https://discord.gg/coredao), we are always available to help. +::: From 28875d9166f54ea5eb51674e09a51c4f7acedf1a Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:44 +0500 Subject: [PATCH 014/837] New translations core-mainnet-wallet-config.md (Spanish) --- .../Dev-Guide/core-mainnet-wallet-config.md | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 docs_es/Dev-Guide/core-mainnet-wallet-config.md diff --git a/docs_es/Dev-Guide/core-mainnet-wallet-config.md b/docs_es/Dev-Guide/core-mainnet-wallet-config.md new file mode 100644 index 0000000000..80705dca40 --- /dev/null +++ b/docs_es/Dev-Guide/core-mainnet-wallet-config.md @@ -0,0 +1,117 @@ +--- +sidebar_label: Core Chain Mainnet +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Connect to Core Chain Mainnet + +--- + +:::note +This is a detailed guideline for connecting to Core Mainnet using the MetaMask wallet. +::: + +## Software Prequisites + +1. [MetaMask Wallet Browser Extension](https://metamask.io/) + +## MetaMask Wallet Setup + +We recommend using the [MetaMask web wallet](https://metamask.io/) to connect to Core Mainnet. You'll need to install MetaMask and set up your account before you can use it to connect to Core Mainnet. You can find MetaMask setup instructions here. + +## Adding Core Mainnet to MetaMask + +There are multiple ways to add Core Mainnet configurations to your MetaMask Wallet, we have listed the most trusted and testest ways below. + +### Adding Network Manually + +1. Click on the network selector button (the downward facing arrow next to the current network). This will display a list of networks to which you’re already connected. + +\mainnet-wallet-config-1 + +2. Click ‘Add network’ at the bottom of the network list + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-2.webp) + +3. A new browser tab will then open, displaying various fields to fill out: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-3.webp) + +Fill in the following network information and click `save` to add the network. + +- **Network Name:** Core Blockchain +- **New RPC URL:** https://rpc.ankr.com/core +- **Chain ID:** 1116 (**Note**: 0x45c is the same as 1116. The new version of MetaMask converts chain ID to hexadecimal format). +- **Currency Symbol:** CORE +- **Block Explorer URL:** https://scan.coredao.org + +4. After performing the above steps, you will be able to see the Core network the next time you access the network selector. + +### Adding the Core network via Chainlist.org + +1. Go to chainlist.org and search for ‘_Core_’ + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-4.webp) + +2. Double check to make sure to choose the right network. Please check the details in the below snapshots — Chain ID, Currency etc. to ensure you will add the correct one. + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-6.webp) + +3. Click the ‘_Add to MetaMask_’ button. + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-7.webp) + +4. Approve the action in your MetaMask by clicking the _‘Approve’_ button. + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-8.webp) + +The Core network is now added to your MetaMask. + +### Adding the Core network via the Core Explorer + +1. Go to https://scan.coredao.org/ and scroll all the way down on the page + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-9.webp) + +2. Click the ‘_Add Core Network_’ button + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-10.webp) + +3. Approve in your MetaMask + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-11.webp) + +4. After performing the above steps, you will be able to see Core network the next time you access the network selector. + +### Adding the Core network to MetaMask mobile wallet: + +1. Tap on the three lines in the top-left corner: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-12.webp) + +2. Select _‘Settings’_: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-13.webp) + +3. Select Networks: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-14.webp) + +4. Tap on ‘_Add Network_’: + +![metmask-mainnet](../../static/img/miannet-wallet-config/mainnet-wallet-config-15.webp) + +5. Fill in the Custom RPC Network details and click _save_ to add the network. + +- **Network Name:** Core Blockchain +- **New RPC URL:** https://rpc.ankr.com/core +- **Chain ID:** 1116 (**Note**: 0x45c is the same as 1116. The new version of MetaMask converts chain ID to hexadecimal format). +- **Currency Symbol:** CORE +- **Block Explorer URL:** https://scan.coredao.org + +4. After performing the above steps, you will be able to see the Core network the next time you access the network selector. + +:::info +If you happen to have an error, or are struggling with adding the network please ask for help in the ‘support’ channel in the [Core Discord](https://discord.gg/coredao), we are always available to help. +::: From 0149776b12a2854dcf61722061a4194daacfc015 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:47 +0500 Subject: [PATCH 015/837] New translations core-subgraph.md (French) --- docs_fr/Dev-Guide/core-subgraph.md | 87 ++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 docs_fr/Dev-Guide/core-subgraph.md diff --git a/docs_fr/Dev-Guide/core-subgraph.md b/docs_fr/Dev-Guide/core-subgraph.md new file mode 100644 index 0000000000..db66ac7b16 --- /dev/null +++ b/docs_fr/Dev-Guide/core-subgraph.md @@ -0,0 +1,87 @@ +--- +sidebar_label: Core Subgraph +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Core Subgraph using GraphQL + +--- + +Developers can use a self-hosted subgraph to extract data from the Core blockchain, processing and storing it for consumption via GraphQL. Let's take a look at how we can create and deploy this powerful tool. + +### Important URLs + +We'll be using some standard URLs throughout this guide, which it’ll help to review before getting started. + +#### MainNet + +
URLUsage
Management URL: https://thegraph.coredao.org/deploy/Used to create/deploy subgraphs (--node or -g).
IPFS URL: https://thegraph.coredao.org/ipfs/Used to deploy subgraphs.
HTTP query URL: https://thegraph.coredao.orgUsed to query data from subgraphs.
Health check URL
https://thegraph-is.coredao.org
Used to check subgraph health.
+ +#### TestNet + +
URLUsage
Management URL:
https://thegraph-node.test.btcs.network
Used to create/deploy subgraphs (--node or -g).
IPFS URL:
https://thegraph-ipfs.test.btcs.network
Used to deploy subgraphs.
HTTP query URL:
https://thegraph.test.btcs.network
Used to query data from subgraphs.
Health check URL
https://thegraph-sub.test.btcs.network
Used to check subgraph health.
+ +### General Subgraph Setup Steps + +#### Create Repository + +To create your subgraph repository, follow the[ official guide from The Graph](https://thegraph.com/docs/en/developing/creating-a-subgraph/). In order to deploy onto the Core graph network, make sure to set your network name in `subgraph.yaml` to core. Depending on your subgraph, there may be a few more changes to make. You’ll find additional details in the full example section below. + +#### Create and Deploy + +To create and deploy your subgraph, execute the following commands in your subgraph project repository. + +```bash +# Create subgraph +graph create your-subgraph-name --node https://thegraph.coredao.org/deploy/ + +# Deploy subgraph +graph deploy your-subgraph-name --node https://thegraph.coredao.org/deploy/ --ipfs https://thegraph.coredao.org/ipfs/ +``` + +The `graph deploy` command should return the HTTP query URL for your subgraph, which you can integrate into your application as appropriate. + +### Example: Deploying a Uniswap V2 subgraph + +Now that we understand the process, let's walk through a full example by setting up a Uniswap V2 subgraph on Core. + +First, clone the Uniswap V2 [subgraph repository](https://github.com/Uniswap/v2-subgraph), navigate to the project folder, then execute the following commands from that directory: + +``` +# Install dependencies with npm (or yarn) +npm install + +# Generate subgraph code +npm run codegen +``` + +Now we'll make a few required changes to the _subgraph.yaml_ and _helpers.ts_ files: + +- _subgraph.yaml_: + - Change network name to `core` on lines 9 and 37. + - Update the factory address on line 11. + - Update the `startBlock` on line 13 to a reasonable block height (current block height available [here](https://scan.coredao.org/)). +- _src/mappings/helpers.ts_: + - Update the factory address on line 11. + +Finally, we'll run the create and deploy commands. In order to avoid compatibility issues, let's use the graph-cli installed in the project (instead of the global version) by prefixing the `graph` command with `./node_modules/.bin/`. + +```bash +# Create a new subgraph called uniswap-4-test +./node_modules/.bin/graph create uniswap-4-test --node https://thegraph.coredao.org/deploy/ + +# Deploy the uniswap-4-test subgraph +./node_modules/.bin/graph deploy uniswap-4-test --node https://thegraph.coredao.org/deploy/ --ipfs https://thegraph.coredao.org/ipfs/ + +# The deploy command should print an HTTP query URL similar to: +# https://thegraph.coredao.org/subgraphs/name/uniswap-4-test +``` + +Well done, your subgraph is deployed! Now you can integrate the HTTP query URL printed by the deploy command into your website and use it to query data. + +### Authorization + +To prevent your subgraph from being overwritten by others, please contact us on [discord](https://discord.com/invite/coredaoofficial) for an authorization key.\ +\ +If you are testing against the TestNet Graph, here is an access token for general testing purpose: **a9a79c2aea604bfaa861ff93d46d0d11**. From 4031be88d3e16f9bf572a1844b42c0e07c982c08 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:48 +0500 Subject: [PATCH 016/837] New translations core-subgraph.md (Spanish) --- docs_es/Dev-Guide/core-subgraph.md | 87 ++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 docs_es/Dev-Guide/core-subgraph.md diff --git a/docs_es/Dev-Guide/core-subgraph.md b/docs_es/Dev-Guide/core-subgraph.md new file mode 100644 index 0000000000..db66ac7b16 --- /dev/null +++ b/docs_es/Dev-Guide/core-subgraph.md @@ -0,0 +1,87 @@ +--- +sidebar_label: Core Subgraph +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Core Subgraph using GraphQL + +--- + +Developers can use a self-hosted subgraph to extract data from the Core blockchain, processing and storing it for consumption via GraphQL. Let's take a look at how we can create and deploy this powerful tool. + +### Important URLs + +We'll be using some standard URLs throughout this guide, which it’ll help to review before getting started. + +#### MainNet + +
URLUsage
Management URL: https://thegraph.coredao.org/deploy/Used to create/deploy subgraphs (--node or -g).
IPFS URL: https://thegraph.coredao.org/ipfs/Used to deploy subgraphs.
HTTP query URL: https://thegraph.coredao.orgUsed to query data from subgraphs.
Health check URL
https://thegraph-is.coredao.org
Used to check subgraph health.
+ +#### TestNet + +
URLUsage
Management URL:
https://thegraph-node.test.btcs.network
Used to create/deploy subgraphs (--node or -g).
IPFS URL:
https://thegraph-ipfs.test.btcs.network
Used to deploy subgraphs.
HTTP query URL:
https://thegraph.test.btcs.network
Used to query data from subgraphs.
Health check URL
https://thegraph-sub.test.btcs.network
Used to check subgraph health.
+ +### General Subgraph Setup Steps + +#### Create Repository + +To create your subgraph repository, follow the[ official guide from The Graph](https://thegraph.com/docs/en/developing/creating-a-subgraph/). In order to deploy onto the Core graph network, make sure to set your network name in `subgraph.yaml` to core. Depending on your subgraph, there may be a few more changes to make. You’ll find additional details in the full example section below. + +#### Create and Deploy + +To create and deploy your subgraph, execute the following commands in your subgraph project repository. + +```bash +# Create subgraph +graph create your-subgraph-name --node https://thegraph.coredao.org/deploy/ + +# Deploy subgraph +graph deploy your-subgraph-name --node https://thegraph.coredao.org/deploy/ --ipfs https://thegraph.coredao.org/ipfs/ +``` + +The `graph deploy` command should return the HTTP query URL for your subgraph, which you can integrate into your application as appropriate. + +### Example: Deploying a Uniswap V2 subgraph + +Now that we understand the process, let's walk through a full example by setting up a Uniswap V2 subgraph on Core. + +First, clone the Uniswap V2 [subgraph repository](https://github.com/Uniswap/v2-subgraph), navigate to the project folder, then execute the following commands from that directory: + +``` +# Install dependencies with npm (or yarn) +npm install + +# Generate subgraph code +npm run codegen +``` + +Now we'll make a few required changes to the _subgraph.yaml_ and _helpers.ts_ files: + +- _subgraph.yaml_: + - Change network name to `core` on lines 9 and 37. + - Update the factory address on line 11. + - Update the `startBlock` on line 13 to a reasonable block height (current block height available [here](https://scan.coredao.org/)). +- _src/mappings/helpers.ts_: + - Update the factory address on line 11. + +Finally, we'll run the create and deploy commands. In order to avoid compatibility issues, let's use the graph-cli installed in the project (instead of the global version) by prefixing the `graph` command with `./node_modules/.bin/`. + +```bash +# Create a new subgraph called uniswap-4-test +./node_modules/.bin/graph create uniswap-4-test --node https://thegraph.coredao.org/deploy/ + +# Deploy the uniswap-4-test subgraph +./node_modules/.bin/graph deploy uniswap-4-test --node https://thegraph.coredao.org/deploy/ --ipfs https://thegraph.coredao.org/ipfs/ + +# The deploy command should print an HTTP query URL similar to: +# https://thegraph.coredao.org/subgraphs/name/uniswap-4-test +``` + +Well done, your subgraph is deployed! Now you can integrate the HTTP query URL printed by the deploy command into your website and use it to query data. + +### Authorization + +To prevent your subgraph from being overwritten by others, please contact us on [discord](https://discord.com/invite/coredaoofficial) for an authorization key.\ +\ +If you are testing against the TestNet Graph, here is an access token for general testing purpose: **a9a79c2aea604bfaa861ff93d46d0d11**. From cd8cf120ee2dac197fa21a75407ab62d0184591d Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:49 +0500 Subject: [PATCH 017/837] New translations core-testnet-wallet-config.md (French) --- .../Dev-Guide/core-testnet-wallet-config.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 docs_fr/Dev-Guide/core-testnet-wallet-config.md diff --git a/docs_fr/Dev-Guide/core-testnet-wallet-config.md b/docs_fr/Dev-Guide/core-testnet-wallet-config.md new file mode 100644 index 0000000000..a75d59ffda --- /dev/null +++ b/docs_fr/Dev-Guide/core-testnet-wallet-config.md @@ -0,0 +1,87 @@ +--- +sidebar_label: Core Chain Testnet +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Connect to Core Chain Testnet + +--- + +:::note +This is a detailed guideline for connecting to Core Testnet using the MetaMask wallet. +::: + +### Software Prequisites + +1. [MetaMask Wallet Browser Extension](https://metamask.io/) + +### MetaMask Wallet Setup + +We recommend using the [MetaMask web wallet](https://metamask.io/) to connect to Core Testnet. You'll need to install MetaMask and set up your account before you can use it to connect to Core Testnet. You can find MetaMask setup instructions here. + +### Adding Core Testnet to MetaMask + +There are multiple ways to add Core Testnet configurations to your MetaMask Wallet, we have listed the most trusted and testest ways below. + +#### Adding Network Manually + +Once you've set up your MetaMask wallet, you can use it to connect to Core Testnet by adding Core Testnet's chain details in MetaMask's network settings. Navigate to `Settings->Networks` in MetaMask and click the `Add Network` button. Input the following information: + +- **Network Name:** Core Blockchain TestNet +- **New RPC URL:** https://rpc.test.btcs.network +- **Chain ID:** 1115 +- **Currency Symbol:** tCORE +- **Block Explorer URL:** https://scan.test.btcs.network + +![add-network-metamask](../../static/img/testnet-wallet-config/testnet-config-wallet-1.png) + +#### Adding the Core network via Chainlist.org + +1. Go to chainlist.org and search for ‘_core blockchain_’, make sure to check the _Include Testnets_ option. + +![chainlist-testnet-connect-metmask](../../static/img/testnet-wallet-config/chainlist-testnet-connect-1.png) + +2. Double check to make sure to choose the right network. Please check the details in the below snapshots — Chain ID, Currency etc. to ensure you will add the correct one. + +![chainlist-testnet-connect-metmask](../../static/img/testnet-wallet-config/chainlist-testnet-connect-2.png) + +3. Click on _Connect Wallet_ and then choose MetaMask. Allow to connect to MetaMask wallet by confirming the MetaMask notifications. + +![chainlist-testnet-connect-metmask](../../static/img/testnet-wallet-config/chainlist-testnet-connect-3.png) + +4. Switch to the Core testnet by clicking the _‘Switch Network’_ button. + +![chainlist-testnet-connect-metmask](../../static/img/testnet-wallet-config/chainlist-testnet-connect-4.png) + +The Core Testnet is now added to your MetaMask. + +#### Adding Network via Core Testnet Explorer + +If you using the Chrome MetaMask extension, you can use a quick shortcut to add Core Testnet to MetaMask. Visit [Core Testnet Explorer](https://scan.test.btcs.network/), scroll down to the bottom, and select the `Add Core Network` button. This will open a pop-up with all necessary network information loaded - you just need to confirm and approve. + +![add-network-metamask](../../static/img/testnet-wallet-config/testnet-wallet-config-2.png) + +:::info + +#### Rebrand Updates + +`Satoshi Chain/BTCs` have been rebranded to `Core Chain/CORE`, respectively. If you added the Testnet before the rebranding, you'll need to update Network Name and Currency Symbol in the MetaMask settings manually; otherwise, you won't be able to use the current version of Core Testnet. Go to `Settings->Network`, and select `Core Testnet` to open up the network settings. Update Network Name and Currency Symbol to the values stated in the [above section](#adding-network-manually) and click the Save button. You're good to go! +::: + +### Funding Wallet with tCORE Tokens + +To help users get started and allow developers to quickly prototype their dApps, Core has released the public [Core Testnet Faucet](https://scan.test.btcs.network/faucet) to distribute Core testnet tokens, **tCORE**. Follow the detailed [guide](./core-faucet.md) to fund your metamask account with tCORE tokens. + +### Sending tCORE Tokens + +You can use MetaMask to send tCORE to other addresses. + +1. Navigate to metamask wallet, make sure you are conencted to Core Testnet +2. Click on the `Send` button + +![send-metmask](../../static/img/testnet-wallet-config/send-tcore-1.png) + +3. Enter the amount of tCORE tokens you want to send and the address whom you want to send the tCORE tokens make sure its a Core Testnet Address. Then click next and confirm the transaction. + +![send-metmask](../../static/img/testnet-wallet-config/send-tcore-2.png) From 6254704118504f80b08b2ebab42b9eba8ae1b6cf Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:50 +0500 Subject: [PATCH 018/837] New translations core-testnet-wallet-config.md (Spanish) --- .../Dev-Guide/core-testnet-wallet-config.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 docs_es/Dev-Guide/core-testnet-wallet-config.md diff --git a/docs_es/Dev-Guide/core-testnet-wallet-config.md b/docs_es/Dev-Guide/core-testnet-wallet-config.md new file mode 100644 index 0000000000..a75d59ffda --- /dev/null +++ b/docs_es/Dev-Guide/core-testnet-wallet-config.md @@ -0,0 +1,87 @@ +--- +sidebar_label: Core Chain Testnet +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Connect to Core Chain Testnet + +--- + +:::note +This is a detailed guideline for connecting to Core Testnet using the MetaMask wallet. +::: + +### Software Prequisites + +1. [MetaMask Wallet Browser Extension](https://metamask.io/) + +### MetaMask Wallet Setup + +We recommend using the [MetaMask web wallet](https://metamask.io/) to connect to Core Testnet. You'll need to install MetaMask and set up your account before you can use it to connect to Core Testnet. You can find MetaMask setup instructions here. + +### Adding Core Testnet to MetaMask + +There are multiple ways to add Core Testnet configurations to your MetaMask Wallet, we have listed the most trusted and testest ways below. + +#### Adding Network Manually + +Once you've set up your MetaMask wallet, you can use it to connect to Core Testnet by adding Core Testnet's chain details in MetaMask's network settings. Navigate to `Settings->Networks` in MetaMask and click the `Add Network` button. Input the following information: + +- **Network Name:** Core Blockchain TestNet +- **New RPC URL:** https://rpc.test.btcs.network +- **Chain ID:** 1115 +- **Currency Symbol:** tCORE +- **Block Explorer URL:** https://scan.test.btcs.network + +![add-network-metamask](../../static/img/testnet-wallet-config/testnet-config-wallet-1.png) + +#### Adding the Core network via Chainlist.org + +1. Go to chainlist.org and search for ‘_core blockchain_’, make sure to check the _Include Testnets_ option. + +![chainlist-testnet-connect-metmask](../../static/img/testnet-wallet-config/chainlist-testnet-connect-1.png) + +2. Double check to make sure to choose the right network. Please check the details in the below snapshots — Chain ID, Currency etc. to ensure you will add the correct one. + +![chainlist-testnet-connect-metmask](../../static/img/testnet-wallet-config/chainlist-testnet-connect-2.png) + +3. Click on _Connect Wallet_ and then choose MetaMask. Allow to connect to MetaMask wallet by confirming the MetaMask notifications. + +![chainlist-testnet-connect-metmask](../../static/img/testnet-wallet-config/chainlist-testnet-connect-3.png) + +4. Switch to the Core testnet by clicking the _‘Switch Network’_ button. + +![chainlist-testnet-connect-metmask](../../static/img/testnet-wallet-config/chainlist-testnet-connect-4.png) + +The Core Testnet is now added to your MetaMask. + +#### Adding Network via Core Testnet Explorer + +If you using the Chrome MetaMask extension, you can use a quick shortcut to add Core Testnet to MetaMask. Visit [Core Testnet Explorer](https://scan.test.btcs.network/), scroll down to the bottom, and select the `Add Core Network` button. This will open a pop-up with all necessary network information loaded - you just need to confirm and approve. + +![add-network-metamask](../../static/img/testnet-wallet-config/testnet-wallet-config-2.png) + +:::info + +#### Rebrand Updates + +`Satoshi Chain/BTCs` have been rebranded to `Core Chain/CORE`, respectively. If you added the Testnet before the rebranding, you'll need to update Network Name and Currency Symbol in the MetaMask settings manually; otherwise, you won't be able to use the current version of Core Testnet. Go to `Settings->Network`, and select `Core Testnet` to open up the network settings. Update Network Name and Currency Symbol to the values stated in the [above section](#adding-network-manually) and click the Save button. You're good to go! +::: + +### Funding Wallet with tCORE Tokens + +To help users get started and allow developers to quickly prototype their dApps, Core has released the public [Core Testnet Faucet](https://scan.test.btcs.network/faucet) to distribute Core testnet tokens, **tCORE**. Follow the detailed [guide](./core-faucet.md) to fund your metamask account with tCORE tokens. + +### Sending tCORE Tokens + +You can use MetaMask to send tCORE to other addresses. + +1. Navigate to metamask wallet, make sure you are conencted to Core Testnet +2. Click on the `Send` button + +![send-metmask](../../static/img/testnet-wallet-config/send-tcore-1.png) + +3. Enter the amount of tCORE tokens you want to send and the address whom you want to send the tCORE tokens make sure its a Core Testnet Address. Then click next and confirm the transaction. + +![send-metmask](../../static/img/testnet-wallet-config/send-tcore-2.png) From 072a917c199e938dad1af1c45088345b110e16ec Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:52 +0500 Subject: [PATCH 019/837] New translations dapp-on-core.md (French) --- docs_fr/Dev-Guide/dapp-on-core.md | 353 ++++++++++++++++++++++++++++++ 1 file changed, 353 insertions(+) create mode 100644 docs_fr/Dev-Guide/dapp-on-core.md diff --git a/docs_fr/Dev-Guide/dapp-on-core.md b/docs_fr/Dev-Guide/dapp-on-core.md new file mode 100644 index 0000000000..96b5beb395 --- /dev/null +++ b/docs_fr/Dev-Guide/dapp-on-core.md @@ -0,0 +1,353 @@ +--- +sidebar_label: Build dApp on Core +hide_table_of_contents: false +sidebar_position: 2 +description: Build a Full Stack dApp on Core Chain +--- + +# Building a dApp on Core + +--- + +Decentralized applications (dApps) use a blockchain or on-chain smart contracts to store and reference data, rather than relying on traditional centralized databases. A common, simple dApp structure generally consists of a React.js or Vue.js front-end using Web3.js or Ethers.js to interact with smart contracts deployed to an EVM-compatible blockchain. + +## What Are We Building + +In this tutorial, we'll develop a simple dApp using React.js and Ethers.js that stores data in a smart contract on the Core blockchain and displays it to users. The dApp's full code is available on GitHub in the [dApp-tutorial](https://github.com/coredao-org/dapp-tutorial/tree/master/01-Basic%20Full%20Stack%20Dapp%20on%20Core#building-a-dapp-on-core) repository. + +## Learning Takeaways + +This tutorial will help you gain knowledge on the following learning points: + +- MetaMask Wallet connectivity to Core Testnet; +- Smart contract development and deployment on Core Testnet; +- Front-end integration with the smart contract using Ethers.js library; +- Read data from a smart contract; +- Write data to a smart contract; + +## Software Prerequisites + +- [Git](https://git-scm.com/) v2.44.0 +- [Node.js](https://nodejs.org/en) v20.11.1 +- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) v10.2.4 +- [Hardhat](https://hardhat.org/hardhat-runner/docs/getting-started#installation) v10.2.4 +- [MetaMask Web Wallet Extension](https://metamask.io/download/) + +## Setting up the development environment + +1. Create a new directory for the project and navigate into it + +```bash +mkdir dapp-tutorial +cd dapp-tutorial +``` + +2. Install [Hardhat](https://hardhat.org/) and [Waffle](https://getwaffle.io/) + +```bash +npm init --yes +npm install --save-dev hardhat +npm install --save-dev chai @nomiclabs/hardhat-waffle +``` + +3. Initialize Hardhat project by running the following command + +```bash +npx hardhat +``` + +![harhat-project-initialize](../../static/img/hardhat/dapp-tutorial-1.png) + +:::note +As we will using Waffle for this project and make sure to select **No** for the option "_Do you want to install this sample project's dependencies with npm (@nomicfoundation/hardhat-toolbox)? (Y/n)_" +::: + +4. Once this project is initialized, you'll find the following project structure: + +```bash +dapp-tutorial. +| .gitignore +| hardhat-config.js (HardHat configuration file.) +| package-lock.json +| package.json +| README.md +| ++---contracts (For Solidity Smart Contracts) +| Lock.sol +| ++---ignition (Scripts in previous versions, this folder contains configuration files that specify how smart contracts should be deployed) +| \---modules +| Lock.js +| ++---node_modules +| ++---test (For writing and Running Tests) +| Lock.js +| +``` + +5. Install and configure MetaMask Chrome Extension to use with Core Testnet. Refer [here](./core-testnet-wallet-config.md) for a detailed guide. + +6. Create a secret.json file in the root folder and store the private key of your MetaMask wallet in it. Refer [here](https://metamask.zendesk.com/hc/en-us/articles/360015290032-How-to-reveal-your-Secret-Recovery-Phrase) for details on how to get MetaMask account's private key. + +```json +{"PrivateKey":"you private key, do not leak this file, do keep it absolutely safe"} +``` + +:::caution +Do not forget to add this file to the `.gitignore` file in the root folder of your project so that you don't accidentally check your private keys/secret phrases into a public repository. Make sure you keep this file in an absolutely safe place! +::: + +7. Copy the following into your `hardhat.config.js` file + +```js +/** + * @type import('hardhat/config').HardhatUserConfig + */ + + +require('@nomiclabs/hardhat-ethers'); +require("@nomiclabs/hardhat-waffle"); + + +const { PrivateKey } = require('./secret.json'); + + +module.exports = { + defaultNetwork: 'testnet', + + + networks: { + hardhat: { + }, + testnet: { + url: 'https://rpc.test.btcs.network', + accounts: [PrivateKey], + chainId: 1115, + } + }, + solidity: { + compilers: [ + { + version: '0.8.19', + settings: { + evmVersion: 'paris', + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, + ], + }, + paths: { + sources: './contracts', + cache: './cache', + artifacts: './artifacts', + }, + mocha: { + timeout: 20000, + }, +}; + +``` + +## Writing Smart Contract + +1. Navigate to the `contracts` folder in the root directory of your project. +2. Delete the `Lock.sol` file; create a new file `Storage.sol` and paste the following contents into it. + +```javascript +// SPDX-License-Identifier: GPL-3.0 + + +pragma solidity >=0.7.0 <0.9.0; + + +/** + * @title Storage + * @dev Store & retrieve value in a variable + */ +contract Storage { + + + uint256 number; + + + /** + * @dev Store value in variable + * @param num value to store + */ + function store(uint256 num) public { + number = num; + } + + + /** + * @dev Return value + * @return value of 'number' + */ + function retrieve() public view returns (uint256){ + return number; + } +} +``` + +### Explanation + +The `Storage` contract is a simple example that demonstrates how to store and retrieve a value using a Solidity smart contract. It consists of a state variable to hold the value and two functions to update and read this value. The `store` function allows any user to set the value, while the `retrieve` function allows any user to read the current value. This contract can be useful for understanding the basics of state variables and function visibility in Solidity. This Solidity smart contract, named `Storage`, is a simple contract that allows storing and retrieving a single `uint256` value. Here’s a detailed breakdown of its components and functionality: + +#### Contract Components + +1. **State Variable**: + - `number`: A `uint256` variable that is used to store the value. + +#### Contract Functions + +1. **Store Function**: + - `store(uint256 num) public`: A function that allows users to store a new value in the `number` variable. This function takes a single parameter, `num`, which is the value to be stored. The function updates the `number` variable with the provided value. + - **Visibility**: The function is marked as `public`, meaning it can be called by any user or contract. + - **State Change**: This function modifies the state of the contract by updating the `number` variable. + +2. **Retrieve Function**: + - `retrieve() public view returns (uint256)`: A function that returns the current value stored in the `number` variable. This function does not take any parameters and returns a `uint256` value. + - **Visibility**: The function is marked as `public`, meaning it can be called by any user or contract. + - **View**: The function is marked as `view`, indicating that it does not modify the state of the contract. It only reads the state. + - **Return Value**: The function returns the value of the `number` variable. + +## Compiling Smart Contract + +1. To compile the `Storage` smart contract defined in the `Storage.sol`, from the root directory run the following command + +```bash +npx hardhat compile +``` + +## Deploy and Interact with Smart Contract + +1. Before deploying your smart contract on the Core Chain, it is best advised to first run a series of tests making sure that the smart contract is working as desired. Refer to the detailed guide [here](https://docs.coredao.org/developer/develop-on-core/building-on-core/using-hardhat#contract-testing) for more details. + +2. Create a `scripts` folder in the root directory of your project. Inside this folder, create a file `deploy-and-call.js`; paste the following script into it. + +```javascript +const hre = require("hardhat"); + + +async function main() { + const Storage = await hre.ethers.getContractFactory("Storage"); + const storage = await Storage.deploy(); + + + await storage.deployed(); + console.log("Storage contract deployed to:", storage.address); + + + console.log("call retrieve():", await storage.retrieve()) + + + console.log("call store(), set value to 100") + const tx = await storage.store(100) + await tx.wait() + + console.log("call retrieve() again:", await storage.retrieve()) +} + + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); +``` + +3. Make sure your MetaMask wallet has tCORE test tokens for the Core Testnet. Refer [here](https://docs.coredao.org/developer/develop-on-core/using-core-testnet/connect-to-core-testnet#testnet-facuet-tcore-account-funding) for details on how to get tCORE tokens from Core Faucet. + +4. Run the following command from the root directory of your project, to deploy your smart contract on the Core Chain. + +```bash +npx hardhat run scripts/deploy-and-call.js +``` + +If successfully deployed, you will get the following output + +```bash +>npx hardhat run scripts/deploy-and-call.js +Storage contract deployed to: 0x48F68BF4A1b1fE6589B9D0a5ad0dF0520582edA2 +call retrieve(): BigNumber { value: "0" } +call store(), set value to 100 +call retrieve() again: BigNumber { value: "100" } +``` + +5. Make sure to save the Address of Storage Contract at which is deployed, as obtained above, this will be used for interacting with smart contract from the dApp's frontend. + +🎉 Congratulations! You have successfully learned how to create, compile, and deploy a smart contract on the Core Chain Testnet using the Hardhat. + +## Interacting with Smart Contract through Frontend + +⚡ ️ Let's create a frontend interface for interacting with the smart contract. + +### Setting up Frontend + +1. Clone the `dApp-tutorial` repository from GitHub using the following command. + +```bash +git clone https://github.com/coredao-org/dapp-tutorial.git +``` + +2. Navigate into the folder `01-Basic Full Stack Dapp on Core` in the cloned `dapp-tutorial` repo. + +```bash +cd dapp-tutorial +cd "01-Basic Full Stack Dapp on Core" +``` + +3. Install all the dependencies, i.e., node modules. + +```bash +npm install +``` + +4. To test if things are working fine, run the application by using the following command. This will serve application with hot reload feature at [http://localhost:5173](http://localhost:5173/) + +```bash +npm run dev +``` + +### Key Implementations + +The application's key blockchain logic is implemented in [App.tsx](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx) + +1. [App.tsx (Wallet)](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx#L20): logic for connecting the application to MetaMask wallet. +2. [App.tsx (Store)](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx#L58): logic to write data to the Storage smart contract. +3. [App.tsx (Retrieve)](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx#L87): logic to read data from the Storage smart contract. + +### Adding Smart Contract Details + +1. Copy the `Storage.sol` file from the `contracts` folder in the root of your project and paste it into the `frontend/src/contracts` folder. +2. Copy the address of the Storage smart contract as obtained in the section [above](#deploy-and-interact-with-smart-contract). +3. Paste this into [Line 10 of App.tsx](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx#L10). + +```javascript +const contractAddress = '0x48F68BF4A1b1fE6589B9D0a5ad0dF0520582edA2' +``` + +4. Additionally, we'll need the ABI metadata to interact with the contract from our dApp. From the `artifacts/contracts` folder in the root of your project. Copy the `Storage.json` file and save it to the `/src/contracts` folder. + +## Test Locally Using MetaMask + +1. Run the command `npm run dev` from the root of the project to start the application. This will serve application with at [http://localhost:5173](http://localhost:5173/) + +2. Make sure that your MetaMask wallet is correctly installed and switched to Core Testnet as described in our [Core Testnet user guide](./core-testnet-wallet-config.md). You'll also need to connect your MetaMask wallet to the local site. + +![dapp-on-core](../../static/img/dapp/dapp-1.png) + +3. Enter a number in the input field and click the **store** button to save it to the contract. A write action on the smart contract invokes the MetaMask wallet. Click the **Confirm** button to sign the transaction and wait for confirmation on the blockchain. + +![dapp-on-core](../../static/img/dapp/dapp-2.avif) + +4. After the transaction is confirmed on the blockchain, click the **retrieve** button to read the value from the smart contract. You will notice the value has been updated. + +![dapp-on-core](../../static/img/dapp/dapp-3.avif) + +🎉 Congratulations! You've just interacted with your newly-deployed contract using your dApp's front end! You can build on the codebase by deploying and interacting with different contracts, and by adding new UI components to the website for your users. From 922bc9c703c5683fd7db89b7772664ab32691a37 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:53 +0500 Subject: [PATCH 020/837] New translations dapp-on-core.md (Spanish) --- docs_es/Dev-Guide/dapp-on-core.md | 353 ++++++++++++++++++++++++++++++ 1 file changed, 353 insertions(+) create mode 100644 docs_es/Dev-Guide/dapp-on-core.md diff --git a/docs_es/Dev-Guide/dapp-on-core.md b/docs_es/Dev-Guide/dapp-on-core.md new file mode 100644 index 0000000000..96b5beb395 --- /dev/null +++ b/docs_es/Dev-Guide/dapp-on-core.md @@ -0,0 +1,353 @@ +--- +sidebar_label: Build dApp on Core +hide_table_of_contents: false +sidebar_position: 2 +description: Build a Full Stack dApp on Core Chain +--- + +# Building a dApp on Core + +--- + +Decentralized applications (dApps) use a blockchain or on-chain smart contracts to store and reference data, rather than relying on traditional centralized databases. A common, simple dApp structure generally consists of a React.js or Vue.js front-end using Web3.js or Ethers.js to interact with smart contracts deployed to an EVM-compatible blockchain. + +## What Are We Building + +In this tutorial, we'll develop a simple dApp using React.js and Ethers.js that stores data in a smart contract on the Core blockchain and displays it to users. The dApp's full code is available on GitHub in the [dApp-tutorial](https://github.com/coredao-org/dapp-tutorial/tree/master/01-Basic%20Full%20Stack%20Dapp%20on%20Core#building-a-dapp-on-core) repository. + +## Learning Takeaways + +This tutorial will help you gain knowledge on the following learning points: + +- MetaMask Wallet connectivity to Core Testnet; +- Smart contract development and deployment on Core Testnet; +- Front-end integration with the smart contract using Ethers.js library; +- Read data from a smart contract; +- Write data to a smart contract; + +## Software Prerequisites + +- [Git](https://git-scm.com/) v2.44.0 +- [Node.js](https://nodejs.org/en) v20.11.1 +- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) v10.2.4 +- [Hardhat](https://hardhat.org/hardhat-runner/docs/getting-started#installation) v10.2.4 +- [MetaMask Web Wallet Extension](https://metamask.io/download/) + +## Setting up the development environment + +1. Create a new directory for the project and navigate into it + +```bash +mkdir dapp-tutorial +cd dapp-tutorial +``` + +2. Install [Hardhat](https://hardhat.org/) and [Waffle](https://getwaffle.io/) + +```bash +npm init --yes +npm install --save-dev hardhat +npm install --save-dev chai @nomiclabs/hardhat-waffle +``` + +3. Initialize Hardhat project by running the following command + +```bash +npx hardhat +``` + +![harhat-project-initialize](../../static/img/hardhat/dapp-tutorial-1.png) + +:::note +As we will using Waffle for this project and make sure to select **No** for the option "_Do you want to install this sample project's dependencies with npm (@nomicfoundation/hardhat-toolbox)? (Y/n)_" +::: + +4. Once this project is initialized, you'll find the following project structure: + +```bash +dapp-tutorial. +| .gitignore +| hardhat-config.js (HardHat configuration file.) +| package-lock.json +| package.json +| README.md +| ++---contracts (For Solidity Smart Contracts) +| Lock.sol +| ++---ignition (Scripts in previous versions, this folder contains configuration files that specify how smart contracts should be deployed) +| \---modules +| Lock.js +| ++---node_modules +| ++---test (For writing and Running Tests) +| Lock.js +| +``` + +5. Install and configure MetaMask Chrome Extension to use with Core Testnet. Refer [here](./core-testnet-wallet-config.md) for a detailed guide. + +6. Create a secret.json file in the root folder and store the private key of your MetaMask wallet in it. Refer [here](https://metamask.zendesk.com/hc/en-us/articles/360015290032-How-to-reveal-your-Secret-Recovery-Phrase) for details on how to get MetaMask account's private key. + +```json +{"PrivateKey":"you private key, do not leak this file, do keep it absolutely safe"} +``` + +:::caution +Do not forget to add this file to the `.gitignore` file in the root folder of your project so that you don't accidentally check your private keys/secret phrases into a public repository. Make sure you keep this file in an absolutely safe place! +::: + +7. Copy the following into your `hardhat.config.js` file + +```js +/** + * @type import('hardhat/config').HardhatUserConfig + */ + + +require('@nomiclabs/hardhat-ethers'); +require("@nomiclabs/hardhat-waffle"); + + +const { PrivateKey } = require('./secret.json'); + + +module.exports = { + defaultNetwork: 'testnet', + + + networks: { + hardhat: { + }, + testnet: { + url: 'https://rpc.test.btcs.network', + accounts: [PrivateKey], + chainId: 1115, + } + }, + solidity: { + compilers: [ + { + version: '0.8.19', + settings: { + evmVersion: 'paris', + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, + ], + }, + paths: { + sources: './contracts', + cache: './cache', + artifacts: './artifacts', + }, + mocha: { + timeout: 20000, + }, +}; + +``` + +## Writing Smart Contract + +1. Navigate to the `contracts` folder in the root directory of your project. +2. Delete the `Lock.sol` file; create a new file `Storage.sol` and paste the following contents into it. + +```javascript +// SPDX-License-Identifier: GPL-3.0 + + +pragma solidity >=0.7.0 <0.9.0; + + +/** + * @title Storage + * @dev Store & retrieve value in a variable + */ +contract Storage { + + + uint256 number; + + + /** + * @dev Store value in variable + * @param num value to store + */ + function store(uint256 num) public { + number = num; + } + + + /** + * @dev Return value + * @return value of 'number' + */ + function retrieve() public view returns (uint256){ + return number; + } +} +``` + +### Explanation + +The `Storage` contract is a simple example that demonstrates how to store and retrieve a value using a Solidity smart contract. It consists of a state variable to hold the value and two functions to update and read this value. The `store` function allows any user to set the value, while the `retrieve` function allows any user to read the current value. This contract can be useful for understanding the basics of state variables and function visibility in Solidity. This Solidity smart contract, named `Storage`, is a simple contract that allows storing and retrieving a single `uint256` value. Here’s a detailed breakdown of its components and functionality: + +#### Contract Components + +1. **State Variable**: + - `number`: A `uint256` variable that is used to store the value. + +#### Contract Functions + +1. **Store Function**: + - `store(uint256 num) public`: A function that allows users to store a new value in the `number` variable. This function takes a single parameter, `num`, which is the value to be stored. The function updates the `number` variable with the provided value. + - **Visibility**: The function is marked as `public`, meaning it can be called by any user or contract. + - **State Change**: This function modifies the state of the contract by updating the `number` variable. + +2. **Retrieve Function**: + - `retrieve() public view returns (uint256)`: A function that returns the current value stored in the `number` variable. This function does not take any parameters and returns a `uint256` value. + - **Visibility**: The function is marked as `public`, meaning it can be called by any user or contract. + - **View**: The function is marked as `view`, indicating that it does not modify the state of the contract. It only reads the state. + - **Return Value**: The function returns the value of the `number` variable. + +## Compiling Smart Contract + +1. To compile the `Storage` smart contract defined in the `Storage.sol`, from the root directory run the following command + +```bash +npx hardhat compile +``` + +## Deploy and Interact with Smart Contract + +1. Before deploying your smart contract on the Core Chain, it is best advised to first run a series of tests making sure that the smart contract is working as desired. Refer to the detailed guide [here](https://docs.coredao.org/developer/develop-on-core/building-on-core/using-hardhat#contract-testing) for more details. + +2. Create a `scripts` folder in the root directory of your project. Inside this folder, create a file `deploy-and-call.js`; paste the following script into it. + +```javascript +const hre = require("hardhat"); + + +async function main() { + const Storage = await hre.ethers.getContractFactory("Storage"); + const storage = await Storage.deploy(); + + + await storage.deployed(); + console.log("Storage contract deployed to:", storage.address); + + + console.log("call retrieve():", await storage.retrieve()) + + + console.log("call store(), set value to 100") + const tx = await storage.store(100) + await tx.wait() + + console.log("call retrieve() again:", await storage.retrieve()) +} + + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); +``` + +3. Make sure your MetaMask wallet has tCORE test tokens for the Core Testnet. Refer [here](https://docs.coredao.org/developer/develop-on-core/using-core-testnet/connect-to-core-testnet#testnet-facuet-tcore-account-funding) for details on how to get tCORE tokens from Core Faucet. + +4. Run the following command from the root directory of your project, to deploy your smart contract on the Core Chain. + +```bash +npx hardhat run scripts/deploy-and-call.js +``` + +If successfully deployed, you will get the following output + +```bash +>npx hardhat run scripts/deploy-and-call.js +Storage contract deployed to: 0x48F68BF4A1b1fE6589B9D0a5ad0dF0520582edA2 +call retrieve(): BigNumber { value: "0" } +call store(), set value to 100 +call retrieve() again: BigNumber { value: "100" } +``` + +5. Make sure to save the Address of Storage Contract at which is deployed, as obtained above, this will be used for interacting with smart contract from the dApp's frontend. + +🎉 Congratulations! You have successfully learned how to create, compile, and deploy a smart contract on the Core Chain Testnet using the Hardhat. + +## Interacting with Smart Contract through Frontend + +⚡ ️ Let's create a frontend interface for interacting with the smart contract. + +### Setting up Frontend + +1. Clone the `dApp-tutorial` repository from GitHub using the following command. + +```bash +git clone https://github.com/coredao-org/dapp-tutorial.git +``` + +2. Navigate into the folder `01-Basic Full Stack Dapp on Core` in the cloned `dapp-tutorial` repo. + +```bash +cd dapp-tutorial +cd "01-Basic Full Stack Dapp on Core" +``` + +3. Install all the dependencies, i.e., node modules. + +```bash +npm install +``` + +4. To test if things are working fine, run the application by using the following command. This will serve application with hot reload feature at [http://localhost:5173](http://localhost:5173/) + +```bash +npm run dev +``` + +### Key Implementations + +The application's key blockchain logic is implemented in [App.tsx](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx) + +1. [App.tsx (Wallet)](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx#L20): logic for connecting the application to MetaMask wallet. +2. [App.tsx (Store)](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx#L58): logic to write data to the Storage smart contract. +3. [App.tsx (Retrieve)](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx#L87): logic to read data from the Storage smart contract. + +### Adding Smart Contract Details + +1. Copy the `Storage.sol` file from the `contracts` folder in the root of your project and paste it into the `frontend/src/contracts` folder. +2. Copy the address of the Storage smart contract as obtained in the section [above](#deploy-and-interact-with-smart-contract). +3. Paste this into [Line 10 of App.tsx](https://github.com/coredao-org/dapp-tutorial/blob/master/01-Simple%20Storage%20Full%20Stack%20Dapp/src/components/App.tsx#L10). + +```javascript +const contractAddress = '0x48F68BF4A1b1fE6589B9D0a5ad0dF0520582edA2' +``` + +4. Additionally, we'll need the ABI metadata to interact with the contract from our dApp. From the `artifacts/contracts` folder in the root of your project. Copy the `Storage.json` file and save it to the `/src/contracts` folder. + +## Test Locally Using MetaMask + +1. Run the command `npm run dev` from the root of the project to start the application. This will serve application with at [http://localhost:5173](http://localhost:5173/) + +2. Make sure that your MetaMask wallet is correctly installed and switched to Core Testnet as described in our [Core Testnet user guide](./core-testnet-wallet-config.md). You'll also need to connect your MetaMask wallet to the local site. + +![dapp-on-core](../../static/img/dapp/dapp-1.png) + +3. Enter a number in the input field and click the **store** button to save it to the contract. A write action on the smart contract invokes the MetaMask wallet. Click the **Confirm** button to sign the transaction and wait for confirmation on the blockchain. + +![dapp-on-core](../../static/img/dapp/dapp-2.avif) + +4. After the transaction is confirmed on the blockchain, click the **retrieve** button to read the value from the smart contract. You will notice the value has been updated. + +![dapp-on-core](../../static/img/dapp/dapp-3.avif) + +🎉 Congratulations! You've just interacted with your newly-deployed contract using your dApp's front end! You can build on the codebase by deploying and interacting with different contracts, and by adding new UI components to the website for your users. From 8f5695f1bfd9987c98365bfc01cce6a4bbf9cd03 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:54 +0500 Subject: [PATCH 021/837] New translations dev-tools.md (French) --- docs_fr/Dev-Guide/dev-tools.md | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docs_fr/Dev-Guide/dev-tools.md diff --git a/docs_fr/Dev-Guide/dev-tools.md b/docs_fr/Dev-Guide/dev-tools.md new file mode 100644 index 0000000000..ea6b1445c9 --- /dev/null +++ b/docs_fr/Dev-Guide/dev-tools.md @@ -0,0 +1,45 @@ +--- +sidebar_label: Developer Tools +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Developer Tooling Landscape + +--- + +#### _Access Core's tools and resources_ + +### Core Blockchain Testnet Resources + +- **[Block Explorer](https://scan.test.btcs.network/):** search and review transactions, accounts, blocks, and more. + +- **[RPC Endpoints](https://chainlist.org/chain/1115):** RPC endpoints for Core Testnet's RPC service. + +- **[Core Faucet](https://scan.test.btcs.network/faucet):** fund your testnet address with tCORE. + +- **[Core Staking](https://stake.test.btcs.network/):** tCORE staking website. + +- **[Gnosis Safe](https://safe.test.btcs.network/welcome):** secure multi-sig management of digital assets. + +### General Resources + +- **[Core DAO GitHub](https://github.com/coredao-org):** the official GitHub Page, including Core blockchain codebase and more. + +### Core Blockchain Mainnet Resources + +- **[Block Explorer](https://scan.coredao.org/):** search and review transactions, accounts, blocks, and more. + +- **[RPC Endpoints](https://chainlist.org/chain/1116):** RPC endpoints for Core Mainnet's RPC service. + +- **[Core Bridge](https://bridge.coredao.org/):** official bridge for the Core ecosystem (more details in Core Bridge Resources) + +- **[Core Staking](https://stake.coredao.org/):** official CORE staking website. + +- **[Web3 Provider](https://cloud.infstones.com/login):** scalable API infrastructure provided by InfStones. + +- **[Core Scan Contract Verifier](https://scan.coredao.org/verifyContract):** web tool for contract verification (guide here). + +- **[Gnosis Safe](https://safe.coredao.org/welcome):** secure multi-sig management of digital assets. + +- **[wCORE](https://scan.coredao.org/address/0x191e94fa59739e188dce837f7f6978d84727ad01):** official wrapped CORE token smart contract. From 73e6defe582684563da2ef488f89d61696fcd372 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:55 +0500 Subject: [PATCH 022/837] New translations dev-tools.md (Spanish) --- docs_es/Dev-Guide/dev-tools.md | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docs_es/Dev-Guide/dev-tools.md diff --git a/docs_es/Dev-Guide/dev-tools.md b/docs_es/Dev-Guide/dev-tools.md new file mode 100644 index 0000000000..ea6b1445c9 --- /dev/null +++ b/docs_es/Dev-Guide/dev-tools.md @@ -0,0 +1,45 @@ +--- +sidebar_label: Developer Tools +hide_table_of_contents: false +sidebar_position: 2 +--- + +# Developer Tooling Landscape + +--- + +#### _Access Core's tools and resources_ + +### Core Blockchain Testnet Resources + +- **[Block Explorer](https://scan.test.btcs.network/):** search and review transactions, accounts, blocks, and more. + +- **[RPC Endpoints](https://chainlist.org/chain/1115):** RPC endpoints for Core Testnet's RPC service. + +- **[Core Faucet](https://scan.test.btcs.network/faucet):** fund your testnet address with tCORE. + +- **[Core Staking](https://stake.test.btcs.network/):** tCORE staking website. + +- **[Gnosis Safe](https://safe.test.btcs.network/welcome):** secure multi-sig management of digital assets. + +### General Resources + +- **[Core DAO GitHub](https://github.com/coredao-org):** the official GitHub Page, including Core blockchain codebase and more. + +### Core Blockchain Mainnet Resources + +- **[Block Explorer](https://scan.coredao.org/):** search and review transactions, accounts, blocks, and more. + +- **[RPC Endpoints](https://chainlist.org/chain/1116):** RPC endpoints for Core Mainnet's RPC service. + +- **[Core Bridge](https://bridge.coredao.org/):** official bridge for the Core ecosystem (more details in Core Bridge Resources) + +- **[Core Staking](https://stake.coredao.org/):** official CORE staking website. + +- **[Web3 Provider](https://cloud.infstones.com/login):** scalable API infrastructure provided by InfStones. + +- **[Core Scan Contract Verifier](https://scan.coredao.org/verifyContract):** web tool for contract verification (guide here). + +- **[Gnosis Safe](https://safe.coredao.org/welcome):** secure multi-sig management of digital assets. + +- **[wCORE](https://scan.coredao.org/address/0x191e94fa59739e188dce837f7f6978d84727ad01):** official wrapped CORE token smart contract. From ddd1cef04821c71fc91b6db5e2f855bfe8936642 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:56 +0500 Subject: [PATCH 023/837] New translations erc20-tokens.md (French) --- docs_fr/Dev-Guide/erc20-tokens.md | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 docs_fr/Dev-Guide/erc20-tokens.md diff --git a/docs_fr/Dev-Guide/erc20-tokens.md b/docs_fr/Dev-Guide/erc20-tokens.md new file mode 100644 index 0000000000..a5327f5fba --- /dev/null +++ b/docs_fr/Dev-Guide/erc20-tokens.md @@ -0,0 +1,69 @@ +--- +sidebar_label: ERC-20 Tokens +hide_table_of_contents: false +sidebar_position: 2 +description: ERC-20 on Core Chain +--- + +# ERC20 Tokens + +--- + +ERC20 is currently the dominant approach to implementing fungible, blockchain-based tokens. Each ERC20 token is based on the original ERC20 token interface, meaning that they all share a common set of functions, including (but not limited to): + +- Transferring tokens from one account to another; +- Getting the current token balance of an account; +- Getting the total supply of the token available on the network; +- Approving an amount of tokens to be spent by a third-party account; + +In order to be ERC-20 compatible, a token must implement all the following functions and events: + +```javascript +function name() public view returns (string) +function symbol() public view returns (string) +function decimals() public view returns (uint8) +function totalSupply() public view returns (uint256) +function balanceOf(address _owner) public view returns (uint256 balance) +function transfer(address _to, uint256 _value) public returns (bool success) +function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) +function approve(address _spender, uint256 _value) public returns (bool success) +function allowance(address _owner, address _spender) public view returns (uint256 remaining) +``` + +```javascript +event Transfer(address indexed _from, address indexed _to, uint256 _value) +event Approval(address indexed _owner, address indexed _spender, uint256 _value) +``` + +## Best Practices + +ERC20 is a simple, secure standard. But we must be careful in our implementation; many ERC20 tokens have been exploited over the years due to the inclusion of additional, buggy code. + +For safety and security, we recommend using the OpenZeppelin ERC20 implementation for your project, the source code for which can be found at[ ERC20.sol](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol). You can do this with the following steps: + +1\. Install OpenZeppelin smart contracts in your project by running the following command: + +`npm install @openzeppelin/contracts` + +2\. Then, you can import the contracts in the library with this: + +```javascript +// contracts/GLDToken.sol +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +contract GLDToken is ERC20 { + constructor(uint256 initialSupply) ERC20("Gold", "GLD") { + _mint(msg.sender, initialSupply); + } +} +``` + +You can find more information on OpenZeppelin ERC-20 implementation [here](https://docs.openzeppelin.com/contracts/4.x/erc20). + +#### References + +- [https://ethereum.org/en/developers/docs/standards/tokens/erc-20/](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) +- [https://docs.openzeppelin.com/contracts/4.x/erc20](https://docs.openzeppelin.com/contracts/4.x/erc20) From cef91c4f92ed743dba91fb1fc13e70b14d096542 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:57 +0500 Subject: [PATCH 024/837] New translations erc20-tokens.md (Spanish) --- docs_es/Dev-Guide/erc20-tokens.md | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 docs_es/Dev-Guide/erc20-tokens.md diff --git a/docs_es/Dev-Guide/erc20-tokens.md b/docs_es/Dev-Guide/erc20-tokens.md new file mode 100644 index 0000000000..a5327f5fba --- /dev/null +++ b/docs_es/Dev-Guide/erc20-tokens.md @@ -0,0 +1,69 @@ +--- +sidebar_label: ERC-20 Tokens +hide_table_of_contents: false +sidebar_position: 2 +description: ERC-20 on Core Chain +--- + +# ERC20 Tokens + +--- + +ERC20 is currently the dominant approach to implementing fungible, blockchain-based tokens. Each ERC20 token is based on the original ERC20 token interface, meaning that they all share a common set of functions, including (but not limited to): + +- Transferring tokens from one account to another; +- Getting the current token balance of an account; +- Getting the total supply of the token available on the network; +- Approving an amount of tokens to be spent by a third-party account; + +In order to be ERC-20 compatible, a token must implement all the following functions and events: + +```javascript +function name() public view returns (string) +function symbol() public view returns (string) +function decimals() public view returns (uint8) +function totalSupply() public view returns (uint256) +function balanceOf(address _owner) public view returns (uint256 balance) +function transfer(address _to, uint256 _value) public returns (bool success) +function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) +function approve(address _spender, uint256 _value) public returns (bool success) +function allowance(address _owner, address _spender) public view returns (uint256 remaining) +``` + +```javascript +event Transfer(address indexed _from, address indexed _to, uint256 _value) +event Approval(address indexed _owner, address indexed _spender, uint256 _value) +``` + +## Best Practices + +ERC20 is a simple, secure standard. But we must be careful in our implementation; many ERC20 tokens have been exploited over the years due to the inclusion of additional, buggy code. + +For safety and security, we recommend using the OpenZeppelin ERC20 implementation for your project, the source code for which can be found at[ ERC20.sol](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol). You can do this with the following steps: + +1\. Install OpenZeppelin smart contracts in your project by running the following command: + +`npm install @openzeppelin/contracts` + +2\. Then, you can import the contracts in the library with this: + +```javascript +// contracts/GLDToken.sol +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +contract GLDToken is ERC20 { + constructor(uint256 initialSupply) ERC20("Gold", "GLD") { + _mint(msg.sender, initialSupply); + } +} +``` + +You can find more information on OpenZeppelin ERC-20 implementation [here](https://docs.openzeppelin.com/contracts/4.x/erc20). + +#### References + +- [https://ethereum.org/en/developers/docs/standards/tokens/erc-20/](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) +- [https://docs.openzeppelin.com/contracts/4.x/erc20](https://docs.openzeppelin.com/contracts/4.x/erc20) From 318bd914ee089c84e09fecdcb7da74b711cb3d67 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:58 +0500 Subject: [PATCH 025/837] New translations erc721-tokens.md (French) --- docs_fr/Dev-Guide/erc721-tokens.md | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 docs_fr/Dev-Guide/erc721-tokens.md diff --git a/docs_fr/Dev-Guide/erc721-tokens.md b/docs_fr/Dev-Guide/erc721-tokens.md new file mode 100644 index 0000000000..6ac09b36ed --- /dev/null +++ b/docs_fr/Dev-Guide/erc721-tokens.md @@ -0,0 +1,77 @@ +--- +sidebar_label: ERC-721 Tokens +hide_table_of_contents: false +sidebar_position: 2 +description: ERC-721 on Core Chain +--- + +# ERC721 Tokens + +--- + +ERC721 is a standard for non-fungible tokens, meaning that each token is verifiably unique from all other tokens, and has become the dominant standard for on-chain NFTs. All ERC721s have a unique `tokenId` that differentiates them from every other token in the set. + +An ERC721-compatible token must implement all the following functions and events: + +```javascript + function balanceOf(address _owner) external view returns (uint256); + function ownerOf(uint256 _tokenId) external view returns (address); + function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable; + function transferFrom(address _from, address _to, uint256 _tokenId) external payable; + function approve(address _approved, uint256 _tokenId) external payable; + function setApprovalForAll(address _operator, bool _approved) external; + function getApproved(uint256 _tokenId) external view returns (address); + function isApprovedForAll(address _owner, address _operator) external view returns (bool); +``` + +```javascript + event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); + event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); + event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); +``` + +## Best Practices + +We recommend using OpenZeppelin's popular and trusted ERC721 implementation in your project. The source code can be found at[ ERC721.sol](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol). You can use OpenZeppelin's ERC721 implementation in your project through the following steps: + +1\. Install the OpenZeppelin library in your project by running the command: + +`npm install @openzeppelin/contracts` + +2\. Once installed, you can use the ERC721 implementation in the library by importing it like this: + +```javascript +// contracts/GameItem.sol +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; +import "@openzeppelin/contracts/utils/Counters.sol"; + +contract GameItem is ERC721URIStorage { + using Counters for Counters.Counter; + Counters.Counter private _tokenIds; + + constructor() ERC721("GameItem", "ITM") {} + + function awardItem(address player, string memory tokenURI) + public + returns (uint256) + { + uint256 newItemId = _tokenIds.current(); + _mint(player, newItemId); + _setTokenURI(newItemId, tokenURI); + + _tokenIds.increment(); + return newItemId; + } +} +``` + +For more information on OpenZeppelin ERC-20 implementation, please read[ ERC721](https://docs.openzeppelin.com/contracts/4.x/erc721). + +#### References + +- [https://ethereum.org/en/developers/docs/standards/tokens/erc-721/](https://ethereum.org/en/developers/docs/standards/tokens/erc-721/) +- [https://docs.openzeppelin.com/contracts/4.x/erc721](https://docs.openzeppelin.com/contracts/4.x/erc721) From a50db141f361bd599c4f3af10401a53bcdee50f2 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:36:59 +0500 Subject: [PATCH 026/837] New translations erc721-tokens.md (Spanish) --- docs_es/Dev-Guide/erc721-tokens.md | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 docs_es/Dev-Guide/erc721-tokens.md diff --git a/docs_es/Dev-Guide/erc721-tokens.md b/docs_es/Dev-Guide/erc721-tokens.md new file mode 100644 index 0000000000..6ac09b36ed --- /dev/null +++ b/docs_es/Dev-Guide/erc721-tokens.md @@ -0,0 +1,77 @@ +--- +sidebar_label: ERC-721 Tokens +hide_table_of_contents: false +sidebar_position: 2 +description: ERC-721 on Core Chain +--- + +# ERC721 Tokens + +--- + +ERC721 is a standard for non-fungible tokens, meaning that each token is verifiably unique from all other tokens, and has become the dominant standard for on-chain NFTs. All ERC721s have a unique `tokenId` that differentiates them from every other token in the set. + +An ERC721-compatible token must implement all the following functions and events: + +```javascript + function balanceOf(address _owner) external view returns (uint256); + function ownerOf(uint256 _tokenId) external view returns (address); + function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable; + function transferFrom(address _from, address _to, uint256 _tokenId) external payable; + function approve(address _approved, uint256 _tokenId) external payable; + function setApprovalForAll(address _operator, bool _approved) external; + function getApproved(uint256 _tokenId) external view returns (address); + function isApprovedForAll(address _owner, address _operator) external view returns (bool); +``` + +```javascript + event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); + event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); + event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); +``` + +## Best Practices + +We recommend using OpenZeppelin's popular and trusted ERC721 implementation in your project. The source code can be found at[ ERC721.sol](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol). You can use OpenZeppelin's ERC721 implementation in your project through the following steps: + +1\. Install the OpenZeppelin library in your project by running the command: + +`npm install @openzeppelin/contracts` + +2\. Once installed, you can use the ERC721 implementation in the library by importing it like this: + +```javascript +// contracts/GameItem.sol +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; +import "@openzeppelin/contracts/utils/Counters.sol"; + +contract GameItem is ERC721URIStorage { + using Counters for Counters.Counter; + Counters.Counter private _tokenIds; + + constructor() ERC721("GameItem", "ITM") {} + + function awardItem(address player, string memory tokenURI) + public + returns (uint256) + { + uint256 newItemId = _tokenIds.current(); + _mint(player, newItemId); + _setTokenURI(newItemId, tokenURI); + + _tokenIds.increment(); + return newItemId; + } +} +``` + +For more information on OpenZeppelin ERC-20 implementation, please read[ ERC721](https://docs.openzeppelin.com/contracts/4.x/erc721). + +#### References + +- [https://ethereum.org/en/developers/docs/standards/tokens/erc-721/](https://ethereum.org/en/developers/docs/standards/tokens/erc-721/) +- [https://docs.openzeppelin.com/contracts/4.x/erc721](https://docs.openzeppelin.com/contracts/4.x/erc721) From 90ed4c6ba16fdf459e65bb4e6e16a932dc862424 Mon Sep 17 00:00:00 2001 From: RumeelHussain <35759187+RumeelHussain@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:37:01 +0500 Subject: [PATCH 027/837] New translations hardhat.md (French) --- docs_fr/Dev-Guide/hardhat.md | 267 +++++++++++++++++++++++++++++++++++ 1 file changed, 267 insertions(+) create mode 100644 docs_fr/Dev-Guide/hardhat.md diff --git a/docs_fr/Dev-Guide/hardhat.md b/docs_fr/Dev-Guide/hardhat.md new file mode 100644 index 0000000000..c947d3a163 --- /dev/null +++ b/docs_fr/Dev-Guide/hardhat.md @@ -0,0 +1,267 @@ +--- +sidebar_label: Using Hardhat +hide_table_of_contents: false +sidebar_position: 2 +description: Deploy Contracts on Core Chain using the Hardhat +--- + +# Using Hardhat + +--- + +Hardhat is a popular development environment for EVM-compatible blockchains, consisting of multiple components for writing, compiling, debugging, and deploying smart contracts. + +In this tutorial, learn how to compile, deploy and call smart contracts on Core TestNet using HardHatcheck. Obtain codebase for this tutorial from [here](https://github.com/coredao-org/hardhat-tutorial). + +## Installation + +Navigate to your profile folder and follow the steps below to install HardHat (npm/node [v8.9.4 LTS or later](https://nodejs.org/en/) is required): + +1. `npm init --yes` +2. `npm install --save-dev hardhat` +3. `npm install --save-dev chai @nomiclabs/hardhat-waffle` + +## Project Initialization + +After installation, we can initialize HardHat by executing the `npx hardhat` command: + +```javascript +$ npx hardhat +888 888 888 888 888 +888 888 888 888 888 +888 888 888 888 888 +8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888 +888 888 "88b 888P" d88" 888 888 "88b "88b 888 +888 888 .d888888 888 888 888 888 888 .d888888 888 +888 888 888 888 888 Y88b 888 888 888 888 888 Y88b. +888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888 + +👷 Welcome to Hardhat v2.10.1 👷‍ + +? What do you want to do? … +❯ Create a JavaScript project + Create a TypeScript project + Create an empty hardhat.config.js + Quit +``` + +Once this project is initialized, you'll find the following project structure: + +- `contracts`: for Solidity smart contracts. +- `scripts`: for JavaScript/TypeScript scripts for contract interaction and other utilities. +- `test`: for writing and running tests. +- `hardhat.config.js`: HardHat configuration file. + +## Configure HardHat for Core Testnet + +Copy the following into your `hardhat.config.js` file: + +```javascript +/** + * @type import('hardhat/config').HardhatUserConfig + */ + + require('@nomiclabs/hardhat-ethers'); + require("@nomiclabs/hardhat-waffle"); + + const { PrivateKey } = require('./secret.json'); + + module.exports = { + defaultNetwork: 'testnet', + + networks: { + hardhat: { + }, + testnet: { + url: 'https://rpc.test.btcs.network', + accounts: [PrivateKey], + chainId: 1115, + } + }, + solidity: { + compilers: [ + { + version: '0.8.9', + settings: { + evmVersion: 'paris', + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, + ], + }, + paths: { + sources: './contracts', + cache: './cache', + artifacts: './artifacts', + }, + mocha: { + timeout: 20000, + }, + }; + +``` + +**Make sure that your smart contract follows the [Solidity Support Guidelines by Core Chain](./smart-contract-guidelines.md)**, to do so ensure that the `evmVersion` parameter is set to `paris` under the solidity compiler settings in the `hardhat.config.js` file. + +> Note that we need to pass in private keys/mnemonic for Provider. You can create a `secret.json` to store them. Do not forget to add this file to the `.gitignore` of your project so that you don't accidentally check your private keys into a public repository. And make sure you keep this file in an absolutely safe place! + +## Writing Smart Contracts + +For the sake of simplicity, let's use the `1_Storage.sol` file we're already familiar with from the Remix tutorial. Copy the code below into a new file called `Storage.sol` and save it to the `contracts` folder. + +```solidity +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +/** + * @title Storage + * @dev Store & retrieve value in a variable + */ +contract Storage { + + uint256 number; + + /** + * @dev Store value in variable + * @param num value to store + */ + function store(uint256 num) public { + number = num; + } + + /** + * @dev Return value + * @return value of 'number' + */ + function retrieve() public view returns (uint256){ + return number; + } +} +``` + +## Contract Compilation + +Run the following command to compile the contract: + +`npx hardhat compile` + +## Contract Testing + +Create a new file called `storage-test.js` containing the following code, and save it to the `test` folder: + +```javascript +const { expect } = require("chai") +const { ethers } = require("hardhat") + +describe("Storage", function () { + let storage; + + beforeEach(async function(){ + Storage = await ethers.getContractFactory("Storage"); + [operator] = await ethers.getSigners(); + storage = await Storage.connect(operator).deploy(); + await storage.deployed() + expect(await storage.retrieve()).to.equal(0n); + }) + describe("Test store function", function(){ + it("should work properly", async function(){ + let tx = await storage.store(100); + await tx.wait(); + expect(await storage.retrieve()).to.equal(100n); + }) + it("should throw", async function(){ + await expect( + storage.store(-1) + ).to.be.throws + }) + }) +}) +``` + +To test our `Storage.sol` contract on the built-in HardHat network, run the following command: + +`npx hardhat test --network hardhat` + +```javascript +$ npx hardhat test --network hardhat + + + Storage + Test store function + ✔ should work properly + ✔ should throw + + + 2 passing (1s) +``` + +## Contract Deployment and Interaction + +HardHat makes it easy to use the `ethers.js` library to deploy and interact with our smart contracts. Create a new file called `deploy-and-call.js` in the `scripts` folder that contains the following code: + +```javascript +// We require the Hardhat Runtime Environment explicitly here. This is optional +// but useful for running the script in a standalone fashion through `node