diff --git a/.gitbook/assets/openzeppelin-example-wallet-faucet01.png b/.gitbook/assets/example-faucet01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-wallet-faucet01.png rename to .gitbook/assets/example-faucet01.png diff --git a/.gitbook/assets/openzeppelin-example-wallet-faucet02.png b/.gitbook/assets/example-faucet02.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-wallet-faucet02.png rename to .gitbook/assets/example-faucet02.png diff --git a/.gitbook/assets/openzeppelin-example-wallet-faucet03.png b/.gitbook/assets/example-faucet03.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-wallet-faucet03.png rename to .gitbook/assets/example-faucet03.png diff --git a/.gitbook/assets/openzeppelin-example-compile.png b/.gitbook/assets/example-openzeppelin-compile01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-compile.png rename to .gitbook/assets/example-openzeppelin-compile01.png diff --git a/.gitbook/assets/openzeppelin-example-createfile03.png b/.gitbook/assets/example-openzeppelin-createfile.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-createfile03.png rename to .gitbook/assets/example-openzeppelin-createfile.png diff --git a/.gitbook/assets/openzeppelin-example-deploy02.png b/.gitbook/assets/example-openzeppelin-deploy01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-deploy02.png rename to .gitbook/assets/example-openzeppelin-deploy01.png diff --git a/.gitbook/assets/openzeppelin-example-deploy03.png b/.gitbook/assets/example-openzeppelin-deploy02.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-deploy03.png rename to .gitbook/assets/example-openzeppelin-deploy02.png diff --git a/.gitbook/assets/openzeppelin-example-deploy04.png b/.gitbook/assets/example-openzeppelin-deploy03.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-deploy04.png rename to .gitbook/assets/example-openzeppelin-deploy03.png diff --git a/.gitbook/assets/openzeppelin-example-flat02.png b/.gitbook/assets/example-openzeppelin-flat01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-flat02.png rename to .gitbook/assets/example-openzeppelin-flat01.png diff --git a/.gitbook/assets/openzeppelin-example-header.png b/.gitbook/assets/example-openzeppelin-header.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-header.png rename to .gitbook/assets/example-openzeppelin-header.png diff --git a/.gitbook/assets/openzeppelin-example-interact01.png b/.gitbook/assets/example-openzeppelin-interact01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-interact01.png rename to .gitbook/assets/example-openzeppelin-interact01.png diff --git a/.gitbook/assets/openzeppelin-example-interact02.png b/.gitbook/assets/example-openzeppelin-interact02.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-interact02.png rename to .gitbook/assets/example-openzeppelin-interact02.png diff --git a/.gitbook/assets/openzeppelin-example-interact03.png b/.gitbook/assets/example-openzeppelin-interact03.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-interact03.png rename to .gitbook/assets/example-openzeppelin-interact03.png diff --git a/.gitbook/assets/openzeppelin-example-interact04.png b/.gitbook/assets/example-openzeppelin-interact04.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-interact04.png rename to .gitbook/assets/example-openzeppelin-interact04.png diff --git a/.gitbook/assets/openzeppelin-example-nft-logo.png b/.gitbook/assets/example-openzeppelin-nft-logo.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-nft-logo.png rename to .gitbook/assets/example-openzeppelin-nft-logo.png diff --git a/.gitbook/assets/openzeppelin-example-verify01.png b/.gitbook/assets/example-openzeppelin-verify01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-verify01.png rename to .gitbook/assets/example-openzeppelin-verify01.png diff --git a/.gitbook/assets/openzeppelin-example-verify02.png b/.gitbook/assets/example-openzeppelin-verify02.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-verify02.png rename to .gitbook/assets/example-openzeppelin-verify02.png diff --git a/.gitbook/assets/openzeppelin-example-verify03.png b/.gitbook/assets/example-openzeppelin-verify03.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-verify03.png rename to .gitbook/assets/example-openzeppelin-verify03.png diff --git a/.gitbook/assets/openzeppelin-example-verify04.png b/.gitbook/assets/example-openzeppelin-verify04.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-verify04.png rename to .gitbook/assets/example-openzeppelin-verify04.png diff --git a/.gitbook/assets/openzeppelin-example-wallet-token02.png b/.gitbook/assets/example-openzeppelin-wallet-token01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-wallet-token02.png rename to .gitbook/assets/example-openzeppelin-wallet-token01.png diff --git a/.gitbook/assets/openzeppelin-example-wallet-token03.png b/.gitbook/assets/example-openzeppelin-wallet-token02.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-wallet-token03.png rename to .gitbook/assets/example-openzeppelin-wallet-token02.png diff --git a/.gitbook/assets/openzeppelin-example-wizard.png b/.gitbook/assets/example-openzeppelin-wizard.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-wizard.png rename to .gitbook/assets/example-openzeppelin-wizard.png diff --git a/.gitbook/assets/openzeppelin-example-deploy01.png b/.gitbook/assets/example-remix-connect01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-deploy01.png rename to .gitbook/assets/example-remix-connect01.png diff --git a/.gitbook/assets/openzeppelin-example-createfile01.png b/.gitbook/assets/example-remix-createfile01.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-createfile01.png rename to .gitbook/assets/example-remix-createfile01.png diff --git a/.gitbook/assets/openzeppelin-example-createfile02.png b/.gitbook/assets/example-remix-createfile02.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-createfile02.png rename to .gitbook/assets/example-remix-createfile02.png diff --git a/.gitbook/assets/openzeppelin-example-flat01.png b/.gitbook/assets/example-remix-flattener.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-flat01.png rename to .gitbook/assets/example-remix-flattener.png diff --git a/.gitbook/assets/openzeppelin-example-wallet-token01.png b/.gitbook/assets/example-xdcpay.png similarity index 100% rename from .gitbook/assets/openzeppelin-example-wallet-token01.png rename to .gitbook/assets/example-xdcpay.png diff --git a/SUMMARY.md b/SUMMARY.md index f4124e7d..a20981df 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -74,7 +74,7 @@ * [Masternode](run-a-node/masternode/README.md) * [Full Node (Docker version)](run-a-node/masternode/full-node.md) * [One-Click-Installer Masternode (Windows OS)](run-a-node/masternode/standby-node.md) - * [One-Click-Installer Masternode (MacOS)](run-a-node/masternode/one-click-installer-masternode-macos.md) + * [One-Click-Installer Masternode (macOS)](run-a-node/masternode/one-click-installer-masternode-macos.md) ## Learn @@ -100,6 +100,7 @@ * [How To Use xdcpay-connect to Create a dApp Connected to XDC network](learn/how-to-articles/how-to-use-xdcpay-connect-to-create-a-dapp-connected-to-xdc-network.md) * [How To Use Truffle and Ganache to Create DeFi App](learn/how-to-articles/how-to-use-truffle-and-ganache-to-create-defi-app.md) * [How to Migrate a dApp from Ethereum to the XDC Network Using Truffle](learn/how-to-articles/how-to-migrate-a-dapp-from-ethereum-to-the-xdc-network-using-truffle.md) + * [How to Migrate from Solana to the XDC Network using Solang](learn/how-to-articles/how-to-migrate-from-solana-to-the-xdc-network-using-solang.md) * [Community Support](learn/community-support.md) * [How to Report an Issue](learn/community-support/how-to-report-an-issue.md) * [Contributing and Feedback Guide](gitbook.md) @@ -108,5 +109,6 @@ * [About](goplugin/about.md) * [How-to Articles](goplugin/how-to-articles.md) -* [Community Support](goplugin/community-support/README.md) +* [Frequently Asked Questions](goplugin/community-support/README.md) * [How to Log a Support Ticket](goplugin/community-support/how-to-log-a-support-ticket.md) + * [How do I check my plugin processes are ok](goplugin/community-support/how-do-i-check-my-plugin-processes-are-ok.md) diff --git a/XRC721-video-tutorials.md b/XRC721-video-tutorials.md new file mode 100644 index 00000000..64c21a2b --- /dev/null +++ b/XRC721-video-tutorials.md @@ -0,0 +1 @@ +XRC721 video tutorials diff --git a/get-started/tokenization.md b/get-started/tokenization.md index be5047c9..7919ade1 100644 --- a/get-started/tokenization.md +++ b/get-started/tokenization.md @@ -1,2 +1,23 @@ # Tokenization +Tokenization is the act of digitizing something of value into the form of a token, or smart contract, on the blockchain. This can range from real-world assets like gold or real estate, to even data. As previously stated, anything that has value can be tokenized on the blockchain. Smart contracts allow these tokenized assets to be programmed for different use cases and provide adaptability to various types of value. + +Tokenizing introduces these valuable assets to the benefits of blockchain, such as security, transparency, speed, and accountability. With blockchain being open-source, these assets can be easily accessed, verified, and transacted, which allows them the ability to easily participate in the evolving economy of Web3. + +### Forms of Value + +There are two forms of value that are represented when using tokenization, which are tangible and intangible. Tangible assets in tokenization are real-world assets with physical form, such art, precious metals, collectibles, etc. Intangible forms of value represent data, licensing, intellectual property, and other item that can not be represented physically. + +### Fungible and Non-Fungible + +#### Fungible + +Fungible means these assets are divisible into smaller units of value. Let's say you wanted to tokenize 1lb gold, you could make the token divisible by 16, which can represent 1oz of that gold bar. This will allow ownership of one item by many, or a single user to transact smaller amounts of one asset. + +#### Non-Fungible + +Non-Fungible means the asset can not be broken down into smaller units of value. This can be used to tokenize assets that are not meant to be shared or divisible. These tokens are usually used to represent a piece of art or any other single asset. + +**** + +**** diff --git a/goplugin/community-support/README.md b/goplugin/community-support/README.md index e84544b3..47248480 100644 --- a/goplugin/community-support/README.md +++ b/goplugin/community-support/README.md @@ -1,33 +1,9 @@ -# Community Support +# Frequently Asked Questions -**Community is the lifeblood and foundation of the XDC Network. Community can be anyone interacting with and contributing to the XDC Network in any way. This can be users, developers, entrepreneurs, enterprise, supporters, and anything else that contributes or builds on the network. Each community participant plays a role in a network's success, and each role has different needs from the ecosystem to successfully contribute. This page, and the rest of XDC Community documentation, will give you access to many outlets and resources that will be needed to join the XDC Network community.** +### PLI FAQs -### Join the XDC Community +[https://docs.goplugin.co/support/faq](https://docs.goplugin.co/support/faq) -There are many ways to join the XDC Network community and engage with others participating in its ecosystem. The following links will get you started. -#### Twitter and Social Media - -[XDC Community](https://twitter.com/xdc\_community) - -[XDC Foundation](https://twitter.com/XDCFoundation) Twitter - -[XDC Foundation](https://www.linkedin.com/company/xdc-foundation/) Linkedin - -[XDC Foundation](https://www.youtube.com/channel/UCXAAtlD-CRraNJKzDTF4pfg/featured) YouTube - -[XinFin](https://twitter.com/XinFin\_Official) Twitter - -[XinFin](https://www.linkedin.com/company/xinfin/) Linkedin - -#### Talk XDC Network - -[Discord](https://discord.gg/MFeHJ6C5gn) XDC Community Discord for building on XDC - -[XDC.DEV](https://www.xdc.dev/) Developers Forum - -[XinFin](https://www.reddit.com/r/xinfin/) Reddit - -[XDC Foundation](https://www.reddit.com/r/XDC\_Foundation/) Reddit #### diff --git a/goplugin/community-support/how-do-i-check-my-plugin-processes-are-ok.md b/goplugin/community-support/how-do-i-check-my-plugin-processes-are-ok.md new file mode 100644 index 00000000..a7234e63 --- /dev/null +++ b/goplugin/community-support/how-do-i-check-my-plugin-processes-are-ok.md @@ -0,0 +1,5 @@ +# How do I check my plugin processes are ok + +Run the following command to show the status of you plugin processes + +`pm2 list or pm2 status` diff --git a/how-to/Migrate/Solana/How-to.md b/how-to/Migrate/Solana/How-to.md index 5e1c309d..95fd2da0 100644 --- a/how-to/Migrate/Solana/How-to.md +++ b/how-to/Migrate/Solana/How-to.md @@ -1 +1,315 @@ -Hello World \ No newline at end of file +# Table of content + - [Overview](#-overview) + - [Install and setup Dev Environment](#-install-and-setup-dev-enviroment) + - [Create a project](#-create-a-project) + - [Create an XDC Network Wallet](#-create-an-xdc-network-wallet) + - [Write a smart contract](#-write-a-smart-contract) + - [Compile and migrate the smart contract from Solana to the XDC Network](#-Compile-and-migrate-the-smart-contract-from-solana-to-the-xdc-network) + +# Overview + +Solana is a new blockchain focusing on performance. It supports smart contracts like Ethereum which they call Programs. You can develop those in Rust, but there's also a new project now to compile Solidity to Solana. In other words you can deploy your contracts written in Solidity now to Solana!. + +### What you will learn + +This guide aims at teaching on how a smart contract with solidity for solana using solang. + +### Solang + +With [Solang](https://solang.readthedocs.io/en/latest/) you can compile smart contracts written in Solidity for Solana and Parity Substrate. It uses the llvm compiler framework to produce WebAssembly (wasm) or BPF contract code. As result, the output is highly optimized, which saves you in gas costs. + +The best way to install Solang is using the [VS Code extension](https://solang.readthedocs.io/en/latest/extension.html). It will automatically install the correct solang binary along with the dependencies. + +Let's do some changes to our solang extension, we need to put the target in the settings of it: + +![solang-target](https://user-images.githubusercontent.com/34518489/195971806-c043bd4e-ec6a-41fc-83ac-62c32a37178a.png) + +If you have solidity extension in VSCode Disable the workspace: + +![disable-solidity](https://user-images.githubusercontent.com/34518489/195971874-c49e3a0e-0a41-4cd6-8cd1-ac76d13cba62.png) + +# Install and setup Dev Environment + +For this guide I will be usuing `Windows` + +There are a few technical requirements before we start. Please install the following: + +- [Node.js v8+ LTS and npm](https://nodejs.org/en/) (comes with Node) +- [Git](https://git-scm.com/) +- [Yarn](https://yarnpkg.com/) (optional but I will use this one) +- [Solang](https://solang.readthedocs.io/en/latest/) + +Once we have those installed, we only need one command to install Truffle: + +```bash +npm install -g truffle +``` + +To verify that Truffle is installed properly, type **`truffle version`** on a terminal. You should see something like: + +```bash +Truffle v5.5.27 (core: 5.5.27) +Ganache v7.4.0 +Solidity v0.5.16 (solc-js) +Node v16.16.0 +Web3.js v1.7.4 +``` + +If you see an error instead, make sure that your npm modules are added to your path. + +### For Windows + +We need to install: + +[Solana Tool Suite](https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-tool) + +```bash +curl https://release.solana.com/v1.14.3/solana-install-init-x86_64-pc-windows-msvc.exe --output C:\solana-install-tmp\solana-install-init.exe --create-dirs +``` +And [Prebuilt Binaries](https://docs.solana.com/cli/install-solana-cli-tools#download-prebuilt-binaries) + +Download the binaries by navigating to https://github.com/solana-labs/solana/releases/latest, download solana-release-x86_64-pc-windows-msvc.tar.bz2, then extract the archive using WinZip or similar. Open a Command Prompt and run: + +```bash +cd solana-release/ +set PATH=%cd%/bin;%PATH% +``` + +If you run this command and all it's ok, you sucessfully installed solana: + +```bash +solana --version +``` + +![Screenshot_6](https://user-images.githubusercontent.com/34518489/195973523-baac3725-7875-4ebb-bdf5-b8d4b4eb86ea.png) + + +# Create a project + +Lets start by setting up our folder, we are creating a project called `solana-migration-xdc`, create a new folder by running on terminal + +```bash +mkdir solana-migration-xdc && cd solana-migration-xdc +``` + +And running `truffle init`. If truffle is correctly installed on your local environment, you should see the following message: + +```bash +Starting init... +================ +> Copying project files to /home/your/path/to/solana-migration-xdc +Init successful, sweet! +Try our scaffold commands to get started: + $ truffle create contract YourContractName # scaffold a contract + $ truffle create test YourTestName # scaffold a test +http://trufflesuite.com/docs +``` +Now we going to install some dependencies for solana: + +```bash +yarn add @solana/solidity @solana/web3.js dotenv @truffle/hdwallet-provider +``` + +I recommend for windows to download the solang.exe. Sometimes the Vs Extension doesn't work properly. Navigate to [hyperledger-solang-releases](https://github.com/hyperledger/solang/releases/) and search for the solang.exe, you can download it directly to your root project: + +![Screenshot_4](https://user-images.githubusercontent.com/34518489/195971737-b3392d35-7758-4604-b8e2-167847cf70bd.png) + + +# Create an XDC Network Wallet + +- Easy way to create a wallet is installing the XDC Pay wallet extension download it from [here](https://chrome.google.com/webstore/detail/xdcpay/bocpokimicclpaiekenaeelehdjllofo) +- Receive 1000 free testnet XDC tokens using [Faucet](https://faucet.apothem.network/) + +# Write a smart contract + +Lets create a simple incrementer.sol in the contracts folder , the incrementer contract should have: + +- a constructor that initializes the `int32` value to the given `init_value`, +- a `inc` method to increment the state value, +- a `get` method to know what is the state value + +Note: `Solang aims to be compatible with Solidity 0.7` + +Write the following code to incrementer.sol: + +```solidity +pragma solidity ^0.7.0; + +contract incrementer { + uint32 private value; + + /// Constructor that initializes the `int32` value to the given `init_value`. + constructor(uint32 initvalue) { + value = initvalue; + } + + /// This increments the value by `by`. + function inc(uint32 by) public { + value += by; + } + + /// Simply returns the current value of our `uint32`. + function get() public view returns (uint32) { + return value; + } +} +``` + +The `Solang extension` should compile the code automatically and a folder `Build` with 2 files: `bundle.so` and `incrementer.abi`. + +# Compile and migrate the smart contract from Solana to the XDC Network + +If the extension doesn't work and you cannot see a build folder, try running this command: + +```bash +solang.exe compile contracts/incrementer.sol --target solana --output build +``` + +If this works properly you will see the folder with the 2 described files. + +![Screenshot_5](https://user-images.githubusercontent.com/34518489/195973424-997ac17e-7463-4fbe-a09b-9cccb8dcf2b0.png) + +Now its compiled with `Solang` we going to deploy it to solana devnet, first lets create a `deployContract.js` file in the project root: + +```jsx +const { Connection, LAMPORTS_PER_SOL, Keypair } = require('@solana/web3.js'); +const { Contract, Program } = require('@solana/solidity'); +const { readFileSync } = require('fs'); + +const INCREMENTER_ABI = JSON.parse(readFileSync('./build/incrementer.abi', 'utf8')); +const PROGRAM_SO = readFileSync('./build/bundle.so'); + +(async function () { + console.log('Connecting to your local Solana node ...'); + const connection = new Connection( + //'https://api.mainnet-beta.solana.com', + 'https://api.devnet.solana.com', + //'http://localhost:8899', + 'confirmed'); + + const payer = Keypair.generate(); + + console.log('Airdropping SOL to a new wallet ...'); + const signature = await connection.requestAirdrop(payer.publicKey, LAMPORTS_PER_SOL); + await connection.confirmTransaction(signature, 'confirmed'); + + const program = Keypair.generate(); + const storage = Keypair.generate(); + + const contract = new Contract(connection, program.publicKey, storage.publicKey, INCREMENTER_ABI, payer); + + await contract.load(program, PROGRAM_SO); + + console.log('Program deployment finished, deploying the incrementer contract ...'); + + await contract.deploy('incrementer', [1], storage, 1000); + + const res = await contract.functions.inc(2); + console.log('Adding number 2 to the value', res) + + const res2 = await contract.functions.get(); + console.log('state: ' + res2.result); +})(); +``` +Run this command to config the devnet url for solana: + +```bash +solana config set --url devnet +``` +Now the RPC and WSS are pointing to the devnet + +![Screenshot_7](https://user-images.githubusercontent.com/34518489/195974147-464d6afb-6b01-437b-ab32-51e45be01ac1.png) + +Run the command: + +```bash +node deployContract.js +``` + +If everything is fine and your deployContract script is right you should see this: + +![Screenshot_8](https://user-images.githubusercontent.com/34518489/195974211-dd984a17-33c7-4843-8081-64e53cd75f53.png) + +### Migrate to XDC + +Here we must first to copy our MNEMONIC phrase from our wallet already installed, so go to the extension and log in with your password and click here: + +![Screenshot_9](https://user-images.githubusercontent.com/34518489/195974467-ecaf5727-b6a4-49fa-8518-00751cee4217.png) + +![Screenshot_10](https://user-images.githubusercontent.com/34518489/195974469-0d78635d-0306-4082-b914-5a2aa0c2fb88.png) + +![Screenshot_11](https://user-images.githubusercontent.com/34518489/195974480-89eac49d-ed64-4072-b724-d28bbd12e87c.png) + +![Screenshot_12](https://user-images.githubusercontent.com/34518489/195974481-795ef5bf-48b7-4f44-b414-cd2aaa6f7fcb.png) + +![Screenshot_13](https://user-images.githubusercontent.com/34518489/195974484-c2cb33c9-008c-4e88-a57a-dc1acee8d572.png) + +Once you have your phrase create an .env file and paste it into a variable called MNEMONIC. + +Go to your truffle-config.js and paste this code: + +```jsx +require("dotenv").config(); +const { MNEMONIC } = process.env; +const HDWalletProvider = require("@truffle/hdwallet-provider"); + +module.exports = { + networks: { + xinfin: { + provider: () => + new HDWalletProvider(MNEMONIC, "https://erpc.xinfin.network"), + network_id: 50, + gasLimit: 6721975, + confirmation: 2, + networkCheckTimeout: 1000000, + timeoutBlocks: 2000, + }, + + apothem: { + provider: () => + new HDWalletProvider(MNEMONIC, "https://erpc.apothem.network"), + network_id: 51, + gasLimit: 6721975, + confirmation: 2, + networkCheckTimeout: 1000000, + timeoutBlocks: 2000, + }, + }, + mocha: {}, + compilers: { + solc: { + version: "0.7.0", + }, + }, +}; +``` +Now go to Migrations folder and create a file `1_incrementer.js` and paste this code: + +```jsx +const incrementer = artifacts.require("incrementer"); + +const VALUE = 1 + +module.exports = function(deployer) { + deployer.deploy(incrementer, [VALUE]); +}; +``` + + +Once your have your truffle-config.js file ready it's time to migrate this contract to XDC network. Run this command: + +```bash +truffle migrate --network apothem +or +truffle migrate --network xinfin +``` +this should be the output: + +![Screenshot_14](https://user-images.githubusercontent.com/34518489/195974665-a6a4638f-5d06-4016-9fec-40fa97d80552.png) + +Copy the transaction hash to check it in the [block explorer](https://explorer.apothem.network/) + +![Screenshot_15](https://user-images.githubusercontent.com/34518489/195974754-2c5a38aa-503b-47fd-87e1-100ea0d8aa0c.png) + +Congrats! you have migrated a solana contract compiled with `Solang` to the `XDC network` + diff --git a/how-to/openzeppelin.md b/how-to/openzeppelin.md index 30892041..bf1be052 100644 --- a/how-to/openzeppelin.md +++ b/how-to/openzeppelin.md @@ -16,7 +16,7 @@ keywords: - erc721 --- -![OpenZeppelin logo](../.gitbook/assets/openzeppelin-example-header.png) +![OpenZeppelin logo](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-header.png) # Overview @@ -43,7 +43,7 @@ OpenZeppelin is a “battle-tested” open-source framework comprised of reusabl OpenZeppelin's [Contracts Wizard](https://wizard.openzeppelin.com/) as an interactive smart contract generator is the easiest way to get started building smart contracts based on OpenZeppelin's components.

- OpenZeppelin Contracts Wizard + OpenZeppelin Contracts Wizard

Select the kind of contract that you want, set your parameters and desired features, and the Wizard will generate all of the code necessary. The resulting code is ready to be compiled and deployed, or it can serve as a starting point and be customized further. @@ -57,7 +57,7 @@ ERC721 is a standard for **non-fungible tokens** and is defined in the [EIP-721 ## Create the contract

- Joe's Free Voucher image + Joe's Free Voucher image

Joe has a Pizza shop and for the opening day, he wants to create a one-time free voucher for each client that show with her web3 wallet. @@ -65,7 +65,7 @@ Joe has a Pizza shop and for the opening day, he wants to create a one-time free Make a simple non-fungible token contract that can be paused and minted only by the owner, we gonna use OpenZeppelin's ERC721 contract for this. Open [Remix IDE](https://remix.xinfin.network/), and let's start creating a new Solidity file named `PizzaFreeVoucher.sol` in the contracts folder:

- How to create a new file in Remix IDE How to create a new file in Remix IDE How to create a new file in Remix IDE + How to create a new file in Remix IDE How to create a new file in Remix IDE How to create a new file in Remix IDE

Most of the OpenZeppelin contracts are expected to be used via inheritance: you will inherit from them when writing your contracts. Here is a possible code for the contract, copy this code below for your `PizzaFreeVoucher.sol`: @@ -141,7 +141,7 @@ With `contract PizzaFreeVoucher is ERC721, Pausable, Ownable, ERC721Burnable` we We just need to compile the Solidity file, by changing the Remix tab to `Solidity Compiler` or just hitting `Ctrl + S` in the editor.

- Compile contract + Compile contract

## Deploy the contract @@ -153,19 +153,19 @@ For this tutorial, we gonna deploy the contract using a web3 wallet compatible w Visit the [XDC Apothem network faucet](https://faucet.apothem.network/), enter the public address of your account, and `Request 1000 XDC`. After the success message from the faucet, you can confirm if you have 1000 XDC tokens transferred to your wallet.

- Apothem Network Faucet Apothem Network Faucet Apothem Network Faucet + Apothem Network Faucet Apothem Network Faucet Apothem Network Faucet

Now that we have gas, deploy the contract we previously create. Just change to deploy tab on your Remix IDE, set the environment to `Injected Provider`, and connect Remix with your *XDCPay* account. Select the `PizzaFreeVoucher` contract and click on `Deploy`.

- Deploy Deploy Deploy + Deploy Deploy Deploy

After that, you should see a pop-up notification to accept/deny the deployment transaction, accept by clicking on `Submit`.

- Verify Verify + Verify Verify

Wait for the blockchain confirmation in the `Transactions` tab of your wallet. You can now copy the transaction hash `0xe487f01b027172ce171f5980e465307da5bdb66a0425904ff8f48f25f797b15d` :partying_face::partying_face: @@ -175,13 +175,13 @@ Wait for the blockchain confirmation in the `Transactions` tab of your wallet. Y Open the [**XDC Apothem Network Explorer**](https://explorer.apothem.network/) and search for the previously copied hash. Here, at explorer, we can check all the transactions that occur on the network, including the deployment of our contract. Check the `To` address, should be your contract address (starting with `xdc...`).

- Verify + Verify

Search for the contract address on the explorer, we can see that the contract isn't verified. Click on `Verify and Publish` that will open the verification page.

- Verify + Verify

Now, we have to submit the source code, name, address, and compiler version of the contract. With this, the final user can confirm if the contract was been verified or not, but also interact with it directly on the explorer. @@ -191,25 +191,25 @@ Now, we have to submit the source code, name, address, and compiler version of t On the bottom-left corner in Remix, open `Plugin Manager` and install the `Flattener` plugin. Change to `Flattener` tab on the left navigation bar and click on `contracts/Flattern PizzaFreeVoucher.sol` (this will copy the flat code to your clipboard).

- Flat the source code Flat the source code + Flat the source code Flat the source code

Back to the verification page, paste this code, and fill in the rest of the information. Finally, click `Submit`.

- Verify + Verify

Once the contract is verified, just navigate to `Contract` > `Read Contract` tab, and here you can perform reading actions, such as getting the balance of an account, getting the contract owner, etc.

- Interact + Interact

Let's mint our first non-fungible token by changing to the `Write Contract` tab. First, connect your web3 wallet by clicking on the `Connect to Web3` button and then call the `SafeMint` method with the address that gonna receive the NFT.

- Interact Interact + Interact Interact

Accept the action by submitting the transaction :rocket: @@ -219,13 +219,13 @@ Accept the action by submitting the transaction :rocket: If the mint transaction was confirmed, congratulations! The target address now has one free pizza voucher.

- Interact + Interact

You can pick the voucher contract address (`xdcF26E1ac69D9e173C96848FbD1bBE8759f5C71106`) and add it to the list of *XDCPay*'s tokens.

- Confirm wallet Confirm wallet Confirm wallet + Confirm wallet Confirm wallet Confirm wallet

Now you can see the voucher NFT in your wallet :rocket::rocket: \ No newline at end of file diff --git a/learn/community-support.md b/learn/community-support.md index 591fc2cd..20fa34da 100644 --- a/learn/community-support.md +++ b/learn/community-support.md @@ -1,14 +1,16 @@ # Community Support -**Community is the lifeblood and foundation of the XDC Network. Community can be anyone interacting with and contributing to the XDC Network in any way. This can be users, developers, entrepreneurs, enterprise, supporters, and anything else that contributes or builds on the network. Each community participant plays a role in a network's success, and each role has different needs from the ecosystem to successfully contribute. This page, and the rest of XDC Community documentation, will give you access to many outlets and resources that will be needed to join the XDC Network community.** +**Community is the lifeblood and foundation of the XDC Network. Community can be anyone interacting with and contributing to the XDC Network in any way. This can be users, developers, entrepreneurs, enterprise, supporters, and anything else that contributes or builds on the network. Each community participant plays a role in a network's success, and each role has different needs from the ecosystem to successfully contribute. This page, and the rest of XDC Community documentation, will give you access to many outlets and resources that will be needed to join the XDC Network community.** ### Join the XDC Community -There are many ways to join the XDC Network community and engage with others participating in its ecosystem. The following links will get you started. +There are many ways to join the XDC Network community and engage with others participating in its ecosystem. The following links will get you started. #### Twitter and Social Media -[XDC Community](https://twitter.com/xdc\_community) +[XDC Community](https://twitter.com/xdc\_community) Twitter + +[XDC Community](https://www.youtube.com/channel/UCMLqsQJMOlLEg9VnaB8zS6w) YouTube [XDC Foundation](https://twitter.com/XDCFoundation) Twitter @@ -24,24 +26,10 @@ There are many ways to join the XDC Network community and engage with others par [Discord](https://discord.gg/MFeHJ6C5gn) XDC Community Discord for building on XDC -[XDC.DEV](https://www.xdc.dev/) Developers Forum +[XDC.DEV](https://www.xdc.dev/) Developers Forum [XinFin](https://www.reddit.com/r/xinfin/) Reddit [XDC Foundation](https://www.reddit.com/r/XDC\_Foundation/) Reddit - - - - - - - - - - - - - - #### diff --git a/learn/how-to-articles/create-and-deploy-your-first-your-first-smart-contract-on-the-xdc-network-using-openzepplin.md b/learn/how-to-articles/create-and-deploy-your-first-your-first-smart-contract-on-the-xdc-network-using-openzepplin.md index 8c8a9b59..7b0d3d6d 100644 --- a/learn/how-to-articles/create-and-deploy-your-first-your-first-smart-contract-on-the-xdc-network-using-openzepplin.md +++ b/learn/how-to-articles/create-and-deploy-your-first-your-first-smart-contract-on-the-xdc-network-using-openzepplin.md @@ -18,7 +18,7 @@ description: Use OpenZeppelin's Smart Contracts to create your tokens. # Create and Deploy Your First Smart Contract on the XDC Network Using OpenZepplin and Remix -![OpenZeppelin](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-header.png) +![OpenZeppelin](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-header.png) ## Overview @@ -44,7 +44,7 @@ OpenZeppelin is a “battle-tested” open-source framework comprised of reusabl OpenZeppelin's [Contracts Wizard](https://wizard.openzeppelin.com/) as an interactive smart contract generator is the easiest way to get started building smart contracts based on OpenZeppelin's components. -![OpenZeppelin Contracts Wizard](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-wizard.png) +![OpenZeppelin Contracts Wizard](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-wizard.png) Select the kind of contract that you want, set your parameters and desired features, and the Wizard will generate all of the code necessary. The resulting code is ready to be compiled and deployed, or it can serve as a starting point and be customized further. @@ -56,13 +56,13 @@ ERC721 is a standard for **non-fungible tokens** and is defined in the [EIP-721 ### Create the contract -![Joe's Free Voucher image](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-nft-logo.png) +![Joe's Free Voucher image](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-nft-logo.png) Joe has a Pizza shop and for the opening day, he wants to create a one-time free voucher for each client that show with her web3 wallet. Make a simple non-fungible token contract that can be paused and minted only by the owner, we gonna use OpenZeppelin's ERC721 contract for this. Open [Remix IDE](https://remix.xinfin.network/), and let's start creating a new Solidity file named `PizzaFreeVoucher.sol` in the contracts folder: -![How to create a new file in Remix IDE](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-createfile01.png) ![How to create a new file in Remix IDE](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-createfile02.png) ![How to create a new file in Remix IDE](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-createfile03.png) +![How to create a new file in Remix IDE](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-remix-createfile01.png) ![How to create a new file in Remix IDE](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-remix-createfile02.png) ![How to create a new file in Remix IDE](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-createfile.png) Most of the OpenZeppelin contracts are expected to be used via inheritance: you will inherit from them when writing your contracts. Here is a possible code for the contract, copy this code below for your `PizzaFreeVoucher.sol`: @@ -136,7 +136,7 @@ With `contract PizzaFreeVoucher is ERC721, Pausable, Ownable, ERC721Burnable` we We just need to compile the Solidity file, by changing the Remix tab to `Solidity Compiler` or just hitting `Ctrl + S` in the editor. -![Compile contract](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-compile.png) +![Compile contract](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-compile01.png) ### Deploy the contract @@ -146,15 +146,15 @@ For this tutorial, we gonna deploy the contract using a web3 wallet compatible w Visit the [XDC Apothem network faucet](https://faucet.apothem.network/), enter the public address of your account, and `Request 1000 XDC`. After the success message from the faucet, you can confirm if you have 1000 XDC tokens transferred to your wallet. -![Apothem Network Faucet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-wallet-faucet01.png) ![Apothem Network Faucet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-wallet-faucet02.png) ![Apothem Network Faucet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-wallet-faucet03.png) +![Apothem Network Faucet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-faucet01.png) ![Apothem Network Faucet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-faucet02.png) ![Apothem Network Faucet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-faucet03.png) Now that we have gas, deploy the contract we previously create. Just change to deploy tab on your Remix IDE, set the environment to `Injected Provider`, and connect Remix with your _XDCPay_ account. Select the `PizzaFreeVoucher` contract and click on `Deploy`. -![Deploy](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-deploy01.png) ![Deploy](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-deploy02.png) ![Deploy](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-deploy03.png) +![Deploy](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-remix-connect01.png) ![Deploy](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-deploy01.png) ![Deploy](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-deploy02.png) After that, you should see a pop-up notification to accept/deny the deployment transaction, accept by clicking on `Submit`. -![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-deploy04.png) ![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-verify01.png) +![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-deploy03.png) ![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-verify01.png) Wait for the blockchain confirmation in the `Transactions` tab of your wallet. You can now copy the transaction hash `0xe487f01b027172ce171f5980e465307da5bdb66a0425904ff8f48f25f797b15d` :partying\_face::partying\_face: @@ -162,11 +162,11 @@ Wait for the blockchain confirmation in the `Transactions` tab of your wallet. Y Open the [**XDC Apothem Network Explorer**](https://explorer.apothem.network/) and search for the previously copied hash. Here, at explorer, we can check all the transactions that occur on the network, including the deployment of our contract. Check the `To` address, should be your contract address (starting with `xdc...`). -![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-verify02.png) +![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-verify02.png) Search for the contract address on the explorer, we can see that the contract isn't verified. Click on `Verify and Publish` that will open the verification page. -![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-verify03.png) +![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-verify03.png) Now, we have to submit the source code, name, address, and compiler version of the contract. With this, the final user can confirm if the contract was been verified or not, but also interact with it directly on the explorer. @@ -174,19 +174,19 @@ Now, we have to submit the source code, name, address, and compiler version of t On the bottom-left corner in Remix, open `Plugin Manager` and install the `Flattener` plugin. Change to `Flattener` tab on the left navigation bar and click on `contracts/Flattern PizzaFreeVoucher.sol` (this will copy the flat code to your clipboard). -![Flat the source code](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-flat01.png) ![Flat the source code](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-flat02.png) +![Flat the source code](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-remix-flattener.png) ![Flat the source code](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-flat01.png) Back to the verification page, paste this code, and fill in the rest of the information. Finally, click `Submit`. -![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-verify04.png) +![Verify](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-verify04.png) Once the contract is verified, just navigate to `Contract` > `Read Contract` tab, and here you can perform reading actions, such as getting the balance of an account, getting the contract owner, etc. -![Interact](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-interact01.png) +![Interact](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-interact01.png) Let's mint our first non-fungible token by changing to the `Write Contract` tab. First, connect your web3 wallet by clicking on the `Connect to Web3` button and then call the `SafeMint` method with the address that gonna receive the NFT. -![Interact](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-interact02.png) ![Interact](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-interact03.png) +![Interact](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-interact02.png) ![Interact](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-interact03.png) Accept the action by submitting the transaction :rocket: @@ -194,10 +194,10 @@ Accept the action by submitting the transaction :rocket: If the mint transaction was confirmed, congratulations! The target address now has one free pizza voucher. -![Interact](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-interact04.png) +![Interact](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-interact04.png) You can pick the voucher contract address (`xdcF26E1ac69D9e173C96848FbD1bBE8759f5C71106`) and add it to the list of _XDCPay_'s tokens. -![Confirm wallet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-wallet-token01.png) ![Confirm wallet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-wallet-token02.png) ![Confirm wallet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/openzeppelin-example-wallet-token03.png) +![Confirm wallet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-xdcpay.png) ![Confirm wallet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-wallet-token01.png) ![Confirm wallet](https://raw.githubusercontent.com/XDC-Community/docs/main/.gitbook/assets/example-openzeppelin-wallet-token02.png) Now you can see the voucher NFT in your wallet :rocket::rocket: diff --git a/learn/how-to-articles/how-to-migrate-from-solana-to-the-xdc-network-using-solang.md b/learn/how-to-articles/how-to-migrate-from-solana-to-the-xdc-network-using-solang.md new file mode 100644 index 00000000..21c5e4ed --- /dev/null +++ b/learn/how-to-articles/how-to-migrate-from-solana-to-the-xdc-network-using-solang.md @@ -0,0 +1,316 @@ +# Table of content + - [Overview](#-overview) + - [Install and setup Dev Environment](#-install-and-setup-dev-enviroment) + - [Create a project](#-create-a-project) + - [Create an XDC Network Wallet](#-create-an-xdc-network-wallet) + - [Write a smart contract](#-write-a-smart-contract) + - [Compile and migrate the smart contract from Solana to the XDC Network](#-Compile-and-migrate-the-smart-contract-from-solana-to-the-xdc-network) + +# Overview + +Solana is a new blockchain focusing on performance. It supports smart contracts like Ethereum which they call Programs. You can develop those in Rust, but there's also a new project now to compile Solidity to Solana. In other words you can deploy your contracts written in Solidity now to Solana!. + +### What you will learn + +This guide aims at teaching on how a smart contract with solidity for solana using solang. + +### Solang + +With [Solang](https://solang.readthedocs.io/en/latest/) you can compile smart contracts written in Solidity for Solana and Parity Substrate. It uses the llvm compiler framework to produce WebAssembly (wasm) or BPF contract code. As result, the output is highly optimized, which saves you in gas costs. + +The best way to install Solang is using the [VS Code extension](https://solang.readthedocs.io/en/latest/extension.html). It will automatically install the correct solang binary along with the dependencies. + +Let's do some changes to our solang extension, we need to put the target in the settings of it: + +![solang-target](https://user-images.githubusercontent.com/34518489/195971806-c043bd4e-ec6a-41fc-83ac-62c32a37178a.png) + +If you have solidity extension in VSCode Disable the workspace: + +![disable-solidity](https://user-images.githubusercontent.com/34518489/195971874-c49e3a0e-0a41-4cd6-8cd1-ac76d13cba62.png) + +# Install and setup Dev Environment + +For this guide I will be usuing `Windows` + +There are a few technical requirements before we start. Please install the following: + +- [Node.js v8+ LTS and npm](https://nodejs.org/en/) (comes with Node) +- [Git](https://git-scm.com/) +- [Yarn](https://yarnpkg.com/) (optional but I will use this one) +- [Solang](https://solang.readthedocs.io/en/latest/) + +Once we have those installed, we only need one command to install Truffle: + +```bash +npm install -g truffle +``` + +To verify that Truffle is installed properly, type **`truffle version`** on a terminal. You should see something like: + +```bash +Truffle v5.5.27 (core: 5.5.27) +Ganache v7.4.0 +Solidity v0.5.16 (solc-js) +Node v16.16.0 +Web3.js v1.7.4 +``` + +If you see an error instead, make sure that your npm modules are added to your path. + +### For Windows + +We need to install: + +[Solana Tool Suite](https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-tool) + +```bash +curl https://release.solana.com/v1.14.3/solana-install-init-x86_64-pc-windows-msvc.exe --output C:\solana-install-tmp\solana-install-init.exe --create-dirs +``` +And [Prebuilt Binaries](https://docs.solana.com/cli/install-solana-cli-tools#download-prebuilt-binaries) + +Download the binaries by navigating to https://github.com/solana-labs/solana/releases/latest, download solana-release-x86_64-pc-windows-msvc.tar.bz2, then extract the archive using WinZip or similar. Open a Command Prompt and run: + +```bash +cd solana-release/ +set PATH=%cd%/bin;%PATH% +``` + +If you run this command and all it's ok, you sucessfully installed solana: + +```bash +solana --version +``` + +![Screenshot_6](https://user-images.githubusercontent.com/34518489/195973523-baac3725-7875-4ebb-bdf5-b8d4b4eb86ea.png) + + +# Create a project + +Lets start by setting up our folder, we are creating a project called `solana-migration-xdc`, create a new folder by running on terminal + +```bash +mkdir solana-migration-xdc && cd solana-migration-xdc +``` + +And running `truffle init`. If truffle is correctly installed on your local environment, you should see the following message: + +```bash +Starting init... +================ +> Copying project files to /home/your/path/to/solana-migration-xdc +Init successful, sweet! +Try our scaffold commands to get started: + $ truffle create contract YourContractName # scaffold a contract + $ truffle create test YourTestName # scaffold a test +http://trufflesuite.com/docs +``` +Now we going to install some dependencies for solana: + +```bash +yarn add @solana/solidity @solana/web3.js dotenv @truffle/hdwallet-provider +``` + +I recommend for windows to download the solang.exe. Sometimes the Vs Extension doesn't work properly. Navigate to [hyperledger-solang-releases](https://github.com/hyperledger/solang/releases/) and search for the solang.exe, you can download it directly to your root project: + +![Screenshot_4](https://user-images.githubusercontent.com/34518489/195971737-b3392d35-7758-4604-b8e2-167847cf70bd.png) + + +# Create an XDC Network Wallet + +- Easy way to create a wallet is installing the XDC Pay wallet extension download it from [here](https://chrome.google.com/webstore/detail/xdcpay/bocpokimicclpaiekenaeelehdjllofo) +- Receive 1000 free testnet XDC tokens using [Faucet](https://faucet.apothem.network/) + +# Write a smart contract + +Lets create a simple incrementer.sol in the contracts folder , the incrementer contract should have: + +- a constructor that initializes the `int32` value to the given `init_value`, +- a `inc` method to increment the state value, +- a `get` method to know what is the state value + +Note: `Solang aims to be compatible with Solidity 0.7` + +Write the following code to incrementer.sol: + +```solidity +pragma solidity ^0.7.0; + +contract incrementer { + uint32 private value; + + /// Constructor that initializes the `int32` value to the given `init_value`. + constructor(uint32 initvalue) { + value = initvalue; + } + + /// This increments the value by `by`. + function inc(uint32 by) public { + value += by; + } + + /// Simply returns the current value of our `uint32`. + function get() public view returns (uint32) { + return value; + } +} +``` + +The `Solang extension` should compile the code automatically and a folder `Build` with 2 files: `bundle.so` and `incrementer.abi`. + +# Compile and migrate the smart contract from Solana to the XDC Network + +If the extension doesn't work and you cannot see a build folder, try running this command: + +```bash +solang.exe compile contracts/incrementer.sol --target solana --output build +``` + +If this works properly you will see the folder with the 2 described files. + +![Screenshot_5](https://user-images.githubusercontent.com/34518489/195973424-997ac17e-7463-4fbe-a09b-9cccb8dcf2b0.png) + +Now its compiled with `Solang` we going to deploy it to solana devnet, first lets create a `deployContract.js` file in the project root: + +```jsx +const { Connection, LAMPORTS_PER_SOL, Keypair } = require('@solana/web3.js'); +const { Contract, Program } = require('@solana/solidity'); +const { readFileSync } = require('fs'); + +const INCREMENTER_ABI = JSON.parse(readFileSync('./build/incrementer.abi', 'utf8')); +const PROGRAM_SO = readFileSync('./build/bundle.so'); + +(async function () { + console.log('Connecting to your local Solana node ...'); + const connection = new Connection( + //'https://api.mainnet-beta.solana.com', + 'https://api.devnet.solana.com', + //'http://localhost:8899', + 'confirmed'); + + const payer = Keypair.generate(); + + console.log('Airdropping SOL to a new wallet ...'); + const signature = await connection.requestAirdrop(payer.publicKey, LAMPORTS_PER_SOL); + await connection.confirmTransaction(signature, 'confirmed'); + + const program = Keypair.generate(); + const storage = Keypair.generate(); + + const contract = new Contract(connection, program.publicKey, storage.publicKey, INCREMENTER_ABI, payer); + + await contract.load(program, PROGRAM_SO); + + console.log('Program deployment finished, deploying the incrementer contract ...'); + + await contract.deploy('incrementer', [1], storage, 1000); + + const res = await contract.functions.inc(2); + console.log('Adding number 2 to the value', res) + + const res2 = await contract.functions.get(); + console.log('state: ' + res2.result); +})(); +``` +Run this command to config the devnet url for solana: + +```bash +solana config set --url devnet +``` +Now the RPC and WSS are pointing to the devnet + +![Screenshot_7](https://user-images.githubusercontent.com/34518489/195974147-464d6afb-6b01-437b-ab32-51e45be01ac1.png) + +Run the command: + +```bash +node deployContract.js +``` + +If everything is fine and your deployContract script is right you should see this: + +![Screenshot_8](https://user-images.githubusercontent.com/34518489/195974211-dd984a17-33c7-4843-8081-64e53cd75f53.png) + +### Migrate to XDC + +Here we must first to copy our MNEMONIC phrase from our wallet already installed, so go to the extension and log in with your password and click here: + +![Screenshot_9](https://user-images.githubusercontent.com/34518489/195974467-ecaf5727-b6a4-49fa-8518-00751cee4217.png) + +![Screenshot_10](https://user-images.githubusercontent.com/34518489/195974469-0d78635d-0306-4082-b914-5a2aa0c2fb88.png) + +![Screenshot_11](https://user-images.githubusercontent.com/34518489/195974480-89eac49d-ed64-4072-b724-d28bbd12e87c.png) + +![Screenshot_12](https://user-images.githubusercontent.com/34518489/195974481-795ef5bf-48b7-4f44-b414-cd2aaa6f7fcb.png) + +![Screenshot_13](https://user-images.githubusercontent.com/34518489/195974484-c2cb33c9-008c-4e88-a57a-dc1acee8d572.png) + +Once you have your phrase create an .env file and paste it into a variable called MNEMONIC. + +Go to your truffle-config.js and paste this code: + +```jsx +require("dotenv").config(); +const { MNEMONIC } = process.env; +const HDWalletProvider = require("@truffle/hdwallet-provider"); + +module.exports = { + networks: { + xinfin: { + provider: () => + new HDWalletProvider(MNEMONIC, "https://erpc.xinfin.network"), + network_id: 50, + gasLimit: 6721975, + confirmation: 2, + networkCheckTimeout: 1000000, + timeoutBlocks: 2000, + }, + + apothem: { + provider: () => + new HDWalletProvider(MNEMONIC, "https://erpc.apothem.network"), + network_id: 51, + gasLimit: 6721975, + confirmation: 2, + networkCheckTimeout: 1000000, + timeoutBlocks: 2000, + }, + }, + mocha: {}, + compilers: { + solc: { + version: "0.7.0", + }, + }, +}; +``` +Now go to Migrations folder and create a file `1_incrementer.js` and paste this code: + +```jsx +const incrementer = artifacts.require("incrementer"); + +const VALUE = 1 + +module.exports = function(deployer) { + deployer.deploy(incrementer, [VALUE]); +}; +``` + + +Once your have your truffle-config.js file ready it's time to migrate this contract to XDC network. Run this command: + +```bash +truffle migrate --network apothem +or +truffle migrate --network xinfin +``` +this should be the output: + +![Screenshot_14](https://user-images.githubusercontent.com/34518489/195974665-a6a4638f-5d06-4016-9fec-40fa97d80552.png) + +Copy the transaction hash to check it in the [block explorer](https://explorer.apothem.network/) + +![Screenshot_15](https://user-images.githubusercontent.com/34518489/195974754-2c5a38aa-503b-47fd-87e1-100ea0d8aa0c.png) + +Congrats! you have migrated a solana contract compiled with `Solang` to the `XDC network` + + diff --git a/run-a-node/masternode/one-click-installer-masternode-macos.md b/run-a-node/masternode/one-click-installer-masternode-macos.md index 9c9702c9..ce6d309d 100644 --- a/run-a-node/masternode/one-click-installer-masternode-macos.md +++ b/run-a-node/masternode/one-click-installer-masternode-macos.md @@ -1,18 +1,20 @@ -# One-Click-Installer Masternode (MacOS) +# One-Click-Installer Masternode (macOS) -## XDC One-Click Installer Set-Up (MacOS) +## XDC One-Click Installer Set-Up (macOS) The XDC developer community has made it easy for new and existing users, even those with little or no technical expertise, to quickly set up a masternode with a simple, one-click installer. +{% embed url="https://www.youtube.com/watch?v=_tQeje9rdxQ" %} -## Setting Up XDC One-Click Installer (MacOS) -1. Download the One-Click Installer: [https://xinfin.org/setup-masternode.php](https://xinfin.org/setup-masternode.php) (This option is available for Windows, Linux, and MacOS) +## Setting Up XDC One-Click Installer (macOS) + +1. Download the One-Click Installer: [https://xinfin.org/setup-masternode.php](https://xinfin.org/setup-masternode.php) (This option is available for Windows, Linux, and macOS)
-A pop up window will come up for you to save the file in the default folder (wherever you have designated the download to be saved) +A pop-up window will come up for you to save the file in the default folder (wherever you have designated the download to be saved)
@@ -20,7 +22,7 @@ A pop up window will come up for you to save the file in the default folder (whe
-3\. Go to the "Applications" folder to find the downloaded file, and click on it. When you do, MacOS has a security feature that will warn you about installing software that cannot be verified as shown below +3\. Go to the "Applications" folder to find the downloaded file, and click on it. When you do, macOS has a security feature that will warn you about installing software because the developer cannot be verified as shown below
@@ -36,11 +38,11 @@ If the lock at the bottom left is locked
-6\. Click on "Open" and this will launch the application. Wait several minutes until the application connects to the network. +6\. Click on "Open", and this will launch the application. Wait several minutes until the application connects to the network.
-7\. Once it starts syncing, you will notice "Peers" number going up and "Blocks" going up as well. If prompted by your MacOS to "allow incoming connections to XinFin Network" click "Allow". You will see the application generate your account. +7\. Once it starts syncing, you will notice the "Peers" number going up and "Blocks" going up. If prompted by your MacOS to "allow incoming connections to XinFin Network" click "Allow." You will see the application generate your account.

Please note that if it takes too long to connect, close the application, and reopen it. This will prompt the application to reconnect.

@@ -48,7 +50,7 @@ If the lock at the bottom left is locked
-You can now verify that your masternode shows up in the Network Stat [page](https://www.xinfin.network/#stats). +You can now verify that your masternode shows up on the Network Stat [page](https://www.xinfin.network/#stats).