Name already in use
++ XDC_Python_SDK_V1/.gitignore +
+ Go to file + +| + | # These are some examples of commonly ignored file patterns. | +
| + | # You should customize this list as applicable to your project. | +
| + | # Learn more about .gitignore: | +
| + | # https://www.atlassian.com/git/tutorials/saving-changes/gitignore | +
| + | + | +
| + | # Node artifact files | +
| + | node_modules/ | +
| + | dist/ | +
| + | + | +
| + | # Compiled Java class files | +
| + | *.class | +
| + | + | +
| + | # Compiled Python bytecode | +
| + | *.py[cod] | +
| + | + | +
| + | # Log files | +
| + | *.log | +
| + | + | +
| + | # Package files | +
| + | *.jar | +
| + | + | +
| + | # Maven | +
| + | target/ | +
| + | dist/ | +
| + | + | +
| + | # JetBrains IDE | +
| + | .idea/ | +
| + | + | +
| + | # Unit test reports | +
| + | TEST*.xml | +
| + | + | +
| + | # Generated by MacOS | +
| + | .DS_Store | +
| + | + | +
| + | # Generated by Windows | +
| + | Thumbs.db | +
| + | + | +
| + | # Applications | +
| + | *.app | +
| + | *.exe | +
| + | *.war | +
| + | + | +
| + | # Large media files | +
| + | *.mp4 | +
| + | *.tiff | +
| + | *.avi | +
| + | *.flv | +
| + | *.mov | +
| + | *.wmv | +
| + | + | +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-.png)

- (1).png)
 (1) (1).png)
 (1).png)
+
-- Select `Create a Javascript project` or `Create a Typescript project` according to your requirement.
-- Specify Hardhat Project root or press enter for already specified path.
-- Specify `y` for yes and `n` for no for adding a .gitignore
-- Press enter for `Do you want to install this sample project's dependencies with npm (@nomicfoundation/hardhat-toolbox)?`
+* Select `Create a Javascript project` or `Create a Typescript project` according to your requirement.
+* Specify Hardhat Project root or press enter for already specified path.
+* Specify `y` for yes and `n` for no for adding a .gitignore
+* Press enter for `Do you want to install this sample project's dependencies with npm (@nomicfoundation/hardhat-toolbox)?`
Note: If you are on windows, install this:
@@ -91,10 +89,9 @@ Note: If you are on windows, install this:
npm install --save-dev @nomicfoundation/hardhat-toolbox
```
-Now, you will have a folder structure as below
-
+Now, you will have a folder structure as below 
-# 💵 Write Smart Contract Using OpenZeppelin
+## 💵 Write Smart Contract Using OpenZeppelin
To use OpenZeppelin contracts, install the package in the project using:
@@ -171,9 +168,9 @@ contract MyToken is ERC20 {
}
```
-## Compile the Contract
+### Compile the Contract
-- To compile the contract, write the following in the terminal:
+* To compile the contract, write the following in the terminal:
```bash
npx hardhat compile
@@ -183,11 +180,11 @@ If this returns errors, check your contract and rectify them.
If everything is correctly configured and there is no errors, you should see the following message on your console:
-```sh
+```
Compiled 5 Solidity files successfully
```
-## Writing a script file to deploy the contract
+### Writing a script file to deploy the contract
For writing the script to deploy the contract, create `deploy.js` in `scripts` folder, if it is already not there. Copy the following code in the `deploy.js`:
@@ -213,19 +210,19 @@ main()
});
```
-- To add the XDC Testnet network to metamask: (If you are using XDCPay, you don't have to follow this step)
+* To add the XDC Testnet network to metamask: (If you are using XDCPay, you don't have to follow this step)
-
+
-- To add XDC mainnet network to metamask: (If you are using XDCPay you don't have to follow this step)
+* To add XDC mainnet network to metamask: (If you are using XDCPay you don't have to follow this step)
-
+
-## Setup .env file
+### Setup .env file
> Make sure you do not push this file to github.
-- Make a `.env` at the root of the project to store the private key and network url.
+* Make a `.env` at the root of the project to store the private key and network url.
```python
XINFIN_NETWORK_URL="enter-network-rpc-url-here"
@@ -242,30 +239,29 @@ PRIVATE_KEY=202e3c9d30bbeca38d6578659919d4c3dc989ae18c16756690877fdc4dfa607f
🚨 **Do not use the Private Key in the example above in production or you can risk losing your assets!** 🚨
-- Dont know how to get your private key? Open your XDCPay wallet extension and click on the three dots on the top-left. This will open a popup.
-
+* Dont know how to get your private key? Open your XDCPay wallet extension and click on the three dots on the top-left. This will open a popup. 
Click on the `Export Private key` inside the popup.
-
+
Enter the password that you used while creating the account.
-
+
Copy your private key. This key will be used to sign transactions when deploying the contract through hardhat.
-
+
-## ⚒ Configuring XDC Mainnet and Apothem Testnet on Hardhat
+### ⚒ Configuring XDC Mainnet and Apothem Testnet on Hardhat
-- To be able to import env file variables, please install `dotenv` from your terminal:
+* To be able to import env file variables, please install `dotenv` from your terminal:
```bash
npm install dotenv
```
-- Open the `hardhat.config.js` file. Now we will add the network url and private key of our wallet to this file, so that we can deploy our contract. Your `harhat.config.js` should look like this.
+* Open the `hardhat.config.js` file. Now we will add the network url and private key of our wallet to this file, so that we can deploy our contract. Your `harhat.config.js` should look like this.
```jsx
require("@nomicfoundation/hardhat-toolbox");
@@ -286,7 +282,7 @@ module.exports = {
};
```
-## 💵 Deploying the contract
+### 💵 Deploying the contract
After writing code for the setup and contract, go back to the terminal. Make sure you are in your project directory and type:
@@ -298,7 +294,7 @@ npx hardhat run scripts/deploy.js --network xinfin
For the testnet:
-```sh
+```
npx hardhat run scripts/deploy.js --network apothem
```
@@ -306,11 +302,11 @@ In either case, you need to have enough funds to pay gas fees on the address tha
If the deployment is sucessful, the console should log the following message after migrations complete processing:
-```sh
+```
My token contract address: 0xc8Ac88d77b9870D289806F54AfF9057f170bAb21
```
-## Flattening the Smart Contract
+### Flattening the Smart Contract
When importing third-party libraries like OpenZeppelin, it becomes necessary to flatten your smart contract and then verify it on the blockscan, because blockscan doesn't have access to the OpenZeppelin's code. When we flatten the code, the OpenZeppelin's code will be included in the same file as your samrt contract.
@@ -328,7 +324,7 @@ npx hardhat flatten ./contracts/MyToken.sol > flattenedMyToken.sol
This will create a new file `flattenedMyToken.sol` which would include flattened code for your smart contract.
-## 🔍 Veryfing Contracts on the Block Explorer
+### 🔍 Veryfing Contracts on the Block Explorer
Once you have successfully deployed your smart contract to the blockchain, it might be interesting to verify your contract on [XinFin Block Explorer](https://explorer.xinfin.network/).
@@ -336,45 +332,30 @@ Change the prefix `0x` to `xdc` to look for your contract on [XinFin Block Explo
In this example, there is a `MyToken` contract deployed on XDC Mainnet at the `0x802555081f6AAcE51559d0650Bf15f242aBe7fd7`. You could search for your newly deployed contract on [XinFin Block Explorer](https://explorer.xinfin.network/):
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-.png)
.png)
