# Web3 Is NEAR Web3, also known as Web 3.0, is an idea for a version of the Internet that is decentralized and based on public blockchains. The concept gained popularity in 2020 and 2021 with interest from cryptocurrency enthusiasts and investments from high-profile technologists and companies. Web3 revolves around the idea of a decentralized Internet. Proponents often contrast this to Web 2.0, where large amounts of the web's data and content are centralized in a fairly small group of companies (often referred to as Big Tech). Specific visions for Web3 differ, but all are heavily based in blockchain technologies, such as various cryptocurrencies and non-fungible tokens (NFTs). Some visions are based around the concepts of decentralized autonomous organizations (DAOs), which seek to enable many people to have equal ownership and governance in an organization. Decentralized finance (DeFi) is another key concept, in which users exchange currency without bank or government involvement. Self-sovereign identity allows users to identify themselves without relying on a centralized authentication system like OAuth. ## What is a blockchain? A blockchain is a particular type of irreversible distributed ledger which combines aspects of both computation and data storage. Each new block which is added contains modifications to the state of the ledger that have been agreed upon by the consensus of the distributed nodes which run the network. ## What is NEAR? NEAR Protocol "NEAR" is a decentralized development platform where developers can host serverless applications and smart contracts that easily connect to "open finance" networks and benefit from an ecosystem of web3 components. ## Why NEAR? Unlike most blockchain-based platforms, NEAR Protocol is built from the ground up to be the easiest in the world for developers and their end users, while still providing the scalability and security you need to serve those users. ## How to get started? ### NEAR Wallet is an in-browser, web-based wallet for creating and interacting with NEAR accounts. You can setup an [account](https://wallet.testnet.near.org/) on `testnet` and start exploring your account features. NEAR has several development networks operating independently of each other with their own account IDs. Because of this, there are several deployed wallets you can use. NEAR Wallet `mainnet` NEAR Wallet `testnet` NEAR Wallet `betanet` We will focus only on : NEAR Wallet `testnet` ### NEAR Explorer NEAR Explorer allows you to view block creations in real time! This useful tool allows you to search for transactions and accounts allowing you to view all interactions between users and smart contracts. Go check: [NEAR Explorer on `testnet`](https://explorer.testnet.near.org/) ### NEAR CLI is a NodeJS command line interface that utilizes near-api-js to connect to and interact with the NEAR blockchain. you should consider this as your first reference to start developing on NEAR. Go check: [NEAR CLI Docs](https://docs.near.org/docs/tools/near-cli) ## Writing your first smart contract We will write a very basic and simple smart contract using Rust language and `near-sdk-rs` then deploy it to `NEAR testnet`. 1- Clone The Smart Contract Template Repository ```shell $ git clone git@github.com:near-examples/rust-template.git voting_contract $ cd voting_contract ``` 2- Open the cloned repository in your editor or VSCode using: ```shell $ code . ``` 3- Change the project name in the `Cargo.toml` file ```toml [package] name = "helloworld_contract" version = "0.1.0" ``` 4- Writing the contract code we will change the struct name to `HelloWorldContract`. ``` rust #[near_bindgen] #[derive(Default,BorshDeserialize, BorshSerialize)] pub struct HelloWorldContract { // SETUP CONTRACT STATE } ``` 5- Write the methods implementations for this contract ```rust #[near_bindgen] impl HelloWorldContract { // ADD CONTRACT METHODS HERE pub fn say_hello(&self) -> String{ return "Hello World!".to_string(); } } ``` 6- Build the project ```shell $ ./build.sh ``` it will create the executable `.wasm` file in `./res` folder. 7- Login with NEAR testnet account ```shell $ npm install -g near-cli # if not installed $ near login $ export ID={YOUR_LOGGED_IN_ACCOUNT_ID} ``` 8- Create Sub-Account to deploy the contract on it ```shell $ near create-account hello.$ID --masterAccount $ID --initialBalance 1 ``` 9- Deploy the contract to the sub-account ```shell $ near deploy --wasmFile ./res/helloworld_contract.wasm --accountId hello.$ID ``` 10- Calling the contract functions ```shell $ near call hello.$ID say_hello '' --accountId $ID # Result: 'Hello World!' ``` That's it. Happy Coding! ------ > If you think this is useful, Please Consider Donation: [eslamx7.near](https://wallet.near.org/send-money) --- > References: > [wikipedia](https://en.wikipedia.org/wiki/Web3) > [NEAR](https://docs.near.org)