50 Answers to the Solidity Basic Questions

50 Answers to the Solidity Basic Questions

  1. What is an Ethereum smart Contract?
    It is a small program that runs on the Ethereum blockchain.
  2. What makes an Ethereum smart contract so special compared to other programs?
    It cannot be stopped, hacked or modified.
  3. Can a smart contract interact with other smart contracts?
    Yes. A smart contract can call function of other smart contract.
  4. Can a Solidity smart contract call an API on the web?
    No. Oracle pattern can call function on the smart contract and feed the data and Solidity smart contract may make use of the data received. Smart contract function can be called always from outside to the smart contract and never other way around
  5. Can a solidity smart contract store a lots of data?
    No. Smart Contract storing data cost a gas. So directly storage data is limited.
  6. Can a smart contract be written in another language than Solidity?
    Yes. Viper, LLL, etc. But Solidity is very popular.
  7. Is Solidity a Dynamically or Statically typed language?
    Statically typed language that means variable types are required to mention. Other language like Java or python where variable do not require to mention type, language figures out the type. We have to be careful about the type of the variable because once the contract is deployed we cannot change, this way we reduce the chances of error.
  8. Is Solidity complied or interpreted?
    Complied. Before run the program it require to compile the program. Different than Java language. Java machine compile on the fly.
  9. What is the file extension of Solidity files?
    .sol
  10. Can a single Solidity file have several smart contracts?
    Yes. However it is better to have single contract in single file in order to mange code better.
  11. What is the typical layout of a Solidity smart contract?
    1. pragma statement for the version of the solidity
    2. contract statement and curly braces. Everything between the curly braces is the part of this contract.
    3. Define some variables.
    4. And functions to read and modify data.
      //pragma statement (required)
      pragma solidity ^0.5.9;
      // contract declaration (required)
      contract A{
      //state variables uint a;
      //functions function foo() {.....}
      }
  12. What is the difference between state and local variables?
    State variables are persisted on Blockchain after a smart contract finishes to execute. Whereas local variable live only during the execution of the function.
    contract A {
    // state variable uint a;
    //functions function foo() {
    uint b;
    //local variable
    }
    }
  13. What is the problem with the following code-1?
    contract Storage{
    uint data; //should update the 'data' storage variable above
    function set (uint _data) external{
    address data = _data;
    }
    }

    The set function redefine the data variable inside its body and this will create a local variable that shadow the state variable defined above.
    Remove the address keyword when you reference the data inside the set function.
  14. What is the problem with the following code-2?
    contract Storage{
    uint data; //Should update the 'data' storage variable above
    function set(uint data) external{
    //data = data?
    }
    }

    The data argument of the set function shadows the data state variable inside the set function. Because of this we can access the data inside the set function. To solve the problem we need to rename the argument from data to underscore data.
  15. What are the 2 variable visibilities for state variables in Solidity?
    private and public.
  16. Who can read private and public variables?
    private → can be read by only function inside the smart contract.
    public → anyone.
  17. What is the default visibility of state variables?
    private.
  18. Are private variables really private?
    No. Private variables are private only for EVM, Ethereum Virtual Machine, the part of the Ethereum that execute Smart Contracts. The data of the Smart Contract is put on the Ethereum Blockchain and all the data in this Blockchain is public.
    You can use a special tool to analyse blockchain data and you will be able to read any variables including private variable of the smart contract.
    Private variables are not really private but a little bit harder to read.
  19. How to deal with private data than?
    1. Do not put private data on blockchain
    2. use hashes
  20. Mention 3 data types that you use often, and explain why.
    uint → integer type mainly use for Ether and token transfer.
    address → it is used for identifying humans in smart contract.
    string → used for naming things.
  21. What are the 2 container types in Solidity?
    mapping and arrays
  22. How to declare an array of integer in Solidity?
    uint[] a;
  23. How to declare a mapping of address to booleans in Solidity?
    mapping(address => bool) a;

    In above example “address” is the key and “bool” is the value.
  24. How to declare a mapping of address to mapping of address of booleans (nested mapping)?
    mapping(address => mapping(address => bool)) a;
    In above example first key “address” and than we have second key “address” and value “bool”.
  25. How to add to an array declared as a state variable?
    by using “push” method.
    uint[] a;
    function add(uint newEntry) external{
    add.push(a);
    }
  26. How to add data to a mapping declared as a state variable?
    mapping(address => bool) a;
    function add(address addr) external {
    a[addr] = true;
    }
  27. How to loop through an array?
    uint[] a;
    for(uint i = 0; i < arr.length; i++){
    // do something with arr[]
    // reading:
    uint a = arr[i]
    // writing:
    arr[i] = a
    }
  28. What is the difference between a uint8 and a uint16?
    uint8 can store → 28-1
    uint16 can store → 216-1
  29. What are the 4 function visibilities in Solidity by increasing permissiveness?
    private → the function can be only be called from inside the same contract.
    internal → the function can be called from inside the same contract or another contract that inherit from it.
    external → the function can only be called from outside the smart contract.
    public → the function can be called from anywhere, from the function and outside the contract.
  30. How to conditionally throw an error, with an error message?
    require(a != b, "My error message")
    Use “require” statement.
    Specify the testing condition. If the testing condition fails than the second argument is the error message.
  31. What are the 2 artifacts produced by the Solidity complier when compiling a smart contract.
    abi
    bytecode
  32. What is the ABI of a smart contract?
    ABI is the define interface of a contract.
    That means, set of functions that can be called from outside the smart contract.
    It is used to interact with the smart contract.
    The idea is to use outside libraries like web3.js.
    The smart contract only defines function signatures i.e. function name, argument type and written types but it does not defines the implementation of function.
    ABI also defines events of the funciton.
  33. In the following contract, which function will be part of the ABI?
    contract A{
    function foo()
    external {....}
    function bar() public {....}
    function baz() internal {....}
    }

    foo and bar will part of ABI.
    baz can only be called from inside and inherited from it.
  34. Does the EVM understands Solidity?
    No, EVM under only byte code which must first be produced by the solidity outside the blockchain.
  35. What is the EVM bytecode?
    EVM byte code is a series of EVM elementary instruction called opcodes.
    These opcodes are very simple instruction like adding number, loading number from memory, etc.
    There are more than 100 opcodes defined in the Ethereum Yellow Paper.
    Coding using opcode will be very tedious so we need higher level language call Solidity for higher level of abstraction.
  36. What are the 2 APIs used to interact with a smart contract?
    eth_sendTransaction
    eth_call

    Transaction cost money and can modify the blockchain.
    Call does not cost money and cannot modify the blockchain.
  37. What is gas?
    Gas is an abstract unit to measure transaction cost.
  38. How is gas paid?
    Gas is paid in ether calculated from the following formula:
    ether cost = gasPrice * gas
    gasPrice is wai / gas generally represent in gwai.
    gas represent the gas cost during the execution of the transaction.
    A transaction also specify a gas limit parameter. Which specifies the maximum number of gas that can be paid by transaction. Without this a transaction can drain all the ether in the wallet.
  39. What happen if there is not enough gas in a transaction?
    Transaction will fail and all state changes will be revert.
  40. Who pays for gas in a transaction?
    The sender of the transaction.
  41. What is the most famous IDE for Solidity?
    Remix.
    Remix – Ethereum IDE
  42. List 2 famous smart contract framework for Solidity.
    • Truffle – most popular framework for developing Solidity smart contract. It allows easy deployment of smart contract to developer blockchain and interact with it.
    • OpenZeppelin – provide reference implementation for a lot of tokens standards like ERC20, ERC721. Before developing smart contract always check whether OpenZeppline have already implementation for the re-use.
  43. Which Javascript Ethereum client can we use to develop Solidity on a local blockchain?
    Ganache – Ganache is a CLI tool that can create a blockchain development on the local computer. It is not connected to any public Ethereum blockchain network.
    Everytime it start it start with fresh blockchain with no data on it.
    It comes with 10 preloaded Ethereum account that can be used to develop the smart contract. All ethers specified in it are fake.
  44. What do you need to deploy a smart contract to the Ethereum Network?
    • bytecode from the smart contract,
    • ethereum address,
    • enough ether to cover the transaction cost,
    • wallet to sign the transaction,
    • tool to create transaction, coordinate the signing of the transaction with wallet and sending the signed transaction to the ethereum blockchain network.
  45. List 4 famous Ethereum wallets
    1. Metamask
    2. MyEtherwallet
    3. Ledger
    4. Trezor
  46. List network where you can deploy a Solidity smart contract.
    • Mainnet – real Ethereum network
    • Ropsten – public test net use fake ethers.
    • Koven – public test net specific for Parity client.
  47. How to manage dates in Solidity?
    Solidity does not have native date type. It is managed by storing timestamp in second and uses uint variable.
  48. How to have the current timestamp in seconds?
    use built in ‘now’ variable.
  49. How to construct a timestamp of 1 day in the future?
    now + 86400 ( number of second in one day)
  50. What are the 2 ways to define custom data structure in solidity?
    • struct,
    • enum.
The 7 Things You Need To Know About Blockchain

The 7 Things You Need To Know About Blockchain

There’s no denying the hype around blockchain technology. But for anyone who wants to get ahead of the game, here’s what they need to know about blockchain in order to capitalize on this groundbreaking new trend.

Blockchain is the technology behind Bitcoin taking into consideration as an example. It’s a decentralized digital ledger of all transactions that happen across the internet. It’s the backbone of the cryptocurrency industry, and it’s been hailed as a potential game-changer for how people and businesses interact with each other. It’s the latest buzzword to enter the technology realm, and here’s everything you need to know about blockchain and why you should be paying attention.

But what exactly is blockchain? Here are 7 things you need to know.

How does it work?

Essentially, a blockchain encrypts information in such a way that it cannot be altered, hacked, or cheated. The blockchain serves as a digital ledger of transactions that is duplicated and distributed across the entire network of computer systems. It is a secure, open-source, distributed database used to keep track of who owns what, and who owes whom. Databases and lists of records are referred to as blocks, and they are cryptographically linked together.

Fig-1 – BlockChain

The first block in the chain is called Genesis Block, whose previous block hash is zero.

http://www.anf.es/pdf/Haber_Stornetta.pdf

The work of Stuart Haber and W. Scott Stornetta from 1991 on How to Time-Stamp a Digital Document and their follow-up paper Improving the Efficiency and Reliability of Digital Time-Stamping introduced the idea of a chain of hashes to create a total order of commitments to a dynamically growing set of documents. 

Cryptography – How SHA256 Hash Works

Our fingerprints are unique to each individual, as we all know. It is highly unlikely that two individuals will have identical fingerprints. It cannot be denied, however, that 1 in 60 million people have a similar fingerprint. In this respect, a fingerprint is considered to be the unique identifier of a person. As a matter of fact, it is used by forensic personnel to identify criminals.

Is there any possibility of attaching some type of unique identification to digital assets to make them identifiable?

One idea for using a digital fingerprint is SHA256, developed by the NSA. SHA-256 is a cryptographic hash function that produces a value of 256 bits.  SHA – Secure Hash Algorithm and 256 stands for 256 bits taken in the hash. Hash is always 64 characters long. 64 characters are hexadecimal (numbers from 0 to 9 and letters A to F).

What is a cryptographic hash function?  Any function that maps arbitrary data (text, video, audio, any kind of digital assets of any length or you can put whole operating system) to a fixed-size value can be called a hash function – a fingerprint. This is the core principle used in the Blockchain.

The following linked video and a demo is a very basic visual explanation of the principles behind a blockchain: https://andersbrownworth.com/blockchain/hash  

There are 5 requirements of the SHA256 hash algorithm and these are:

1. One-way: The conversion from digital asset to hash must be one-way.

Fig-2 Hash

This means that the original copy cannot be recreated or restored or reverse Engineer using the hash function. As with fingerprints, no one can recreate a person using its fingerprint.

2. Deterministic: Every time it generates a hash for the same digital asset, it should be the same.

3. It must have fast computation.

4. The Avalanche Effect: It means that, even if a small change is made to the document, the hash will change completely. It is implemented in this manner in the algorithm. A small change may have a significant impact on the algorithm’s output.

5. It must withstand collision: Similar to the case of fingerprint, that 1 in 60 million may have the same fingerprint. There may be a chance that two arbitrary documents may have the same hash function. It is because 64-character combinations are still limited while the creation of digital assets is limitless. Therefore, it is likely at some point that a collision will occur. This is called the pigeon hole principle.  

Fig-3 – pigeonhole  

“In mathematics, the pigeonhole principle states that if {\displaystyle n}n items are put into {\displaystyle m}m containers, with {\displaystyle n>m}n>m, then at least one container must contain more than one item.” Wikipedia. It must be possible for the algorithm to handle it even though it is very rare.   

Refer to chapter 1 of the below-linked book for more details on the SHA256 Hash Algorithm.

https://webspace.science.uu.nl/~tel00101/liter/Books/CrypCont.pdf

Immutable Ledger

Immutable means “impervious to change.” Ledger is a fancy term for the record, which refers to something recorded. In other words, an immutable ledger is a record that cannot be altered.

We can trust digital data in the digital age if the data is secure and hasn’t been altered.

When tracking money transactions, trust and proof of trust are very significant. Let’s say you sent me an e-funds transfer of $100 without any proof that you did so and without any way to verify that you did so. When the money showed up, I would believe you, and if it did not show up–what then?

Banks and credit card companies use ledgers to keep track of transactions. Can we trust them? If we do not wish to hand over our money to a large corporation, bank, or government, what can we do?

Blockchain technology introduced the concept of the Immutable Ledger. Mathematics underlies this concept. Knowing it can’t be altered or changed, you put your trust in that math. 

What does the blockchain do to ensure its immutability? The hash is its foundation. Hashes are like digital signatures, and if a hacker tampers with the ledger, its hash will change. 

The blockchain will reject the hash if it no longer matches the previous hash in the ledger, making it null and void like a bad check.

Fig-4 – BlockChain-hack

It means that the hacker would have to change the next block, the one after that, and the entire blockchain itself. 

Distributed P2P Network

A distributed peer-to-peer network is one where every participating node is equal and independent. This means no single entity can control the network or the resources of the network. In addition, it enables participating users to make money by sharing the processing power and storage capacity of their systems with other users in need. The user with excess processing power can rent it out to users who have a specific job he or she cannot accomplish alone. 

Decentralization of network able to lends itself to different applications and services such as distributed storage and bandwidth, digital content distribution, cryptocurrencies, prediction markets, and much more.

Blockchain is distributed network technology where everyone has a copy of all the transactions blocks, which is stored in every node. The data on these blocks is encrypted and shared among all of the participating peers. In fact, everyone has access to a copy of the entire network and is able to see who owns what. The transactional records cannot be changed retrospectively without altering all subsequent blocks and collusion of the network. All of the transaction data is stored in a decentralized fashion, without a single point of failure. Such Peer-to-peer sharing of information directly between peers without the involvement of a central third party makes a P2P network. 

It is important to understand the difference between “distributed” and “decentralized”.

“distributed” means that not all transactions are processed in the same place, while “decentralized” means that no single entity controls the entire process.

Fig 5 – (a) centralized (b) decentralized (c) distributed

[source: https://medium.com/@VitalikButerin/the-meaning-of-decentralization-a0c92b76a274]

How Mining Works

Here is the simple analogy of Blockchain Mining:

I tell my friends that I am considering a number between one and 100, and on a paper, I write the number and seal it inside an envelope.
 
There’s no need for my friends to guess the exact number; just that they must be the first to guess any number lower than or equal to the one I am thinking of. It does not matter how many guesses they get.
Let me say that I am thinking of the number 19. If Frіеnd A guеѕѕеѕ 21, they lоѕе bесаuѕе оf 21 is greater than 19. If Frіеnd B guesses 16 and Friend C guеѕѕеѕ 12, then they have both thеоrеtісаllу аrrіvеd аt vіаblе аnѕwеrѕ, because of 16<19 and 12<19. Thеrе is no “еxtrа сrеdіt” for Frіеnd B; even thоugh B’ѕ аnѕwеr was closer to thе target аnѕwеr оf 19. 

Nоw imagine that I роѕе the guess whаt number I am thinking? But this time I am nоt asking just three frіеndѕ, аnd I am nоt thіnkіng оf a number bеtwееn 1 аnd 100. Rаthеr, I am asking millions оf wоuld bе mіnеrѕ, and I am thinking оf a 64-dіgіt hexadecimal numbеr. Do you believe that іt iѕ gоіng tо bе extremely hаrd tо guеѕѕ?

Comparing to above аnаlоgу, where thе number 19 оn a ріесе of рареr іn a sealed envelope, in bitcoin mining tеrmѕ, thаt metaphorical undisclosed numbеr іn the envelope іѕ called thе tаrgеt hаѕh – 64 Digit Hexadecimal Number.

Whаt Iѕ a “64-Digit Hеxаdесіmаl Numbеr?
The following Hexadecimal number is any example оf such a numbеr:
0000000000000000057fсс708сf0130d95е27с5819203е9f967ас56е4df598ее
The numbеr above hаѕ 64 dіgіtѕ.

Mіnеrѕ are dоіng wіth those massive computers аnd dоzеnѕ оf сооlіng fаnѕ is guеѕѕіng аt thе tаrgеt hаѕh. Mіnеrѕ makes these guеѕѕеѕ by randomly gеnеrаtіng as many “nоnсеѕ” аѕ “роѕѕіblе, as fаѕt аѕ possible. 

A nоnсе іѕ short fоr “numbеr оnlу used оnсе,” and thе nоnсе is the kеу tо gеnеrаtіng thеѕе 64-bit hеxаdесіmаl numbеrѕ. 
In Bitcoin mіnіng, a nonce іѕ 32 bіtѕ іn ѕіzе—muсh smaller thаn thе hash, which іѕ 256 bits. Thе fіrѕt mіnеr whоѕе nonce gеnеrаtеѕ a hаѕh thаt іѕ lеѕѕ thаn оr еԛuаl tо thе target hаѕh іѕ аwаrdеd сrеdіt fоr соmрlеtіng thаt block and is аwаrdеd.

Byzantine Fault Tolerance

To illustrate how a group of Byzantine generals could have communication problems when trying to decide on their next move, the Byzantine Generals’ Problem was devised in 1982.

The generals have their own armies, and each army is positioned at different locations around the city they plan to capture. They must decide whether to attack or retreat. If all generals reach a consensus, i.e., agree on a common decision that will be executed in coordination, it does not matter if they attack or retreat.

Now there are the following requirements:

  • Decisions must be made by generals regarding attacking or retreating (yes or no);
  • Once a decision is made, it cannot be changed;
  • All generals must agree upon a synchronized decision.

Generals are only able to communicate with each other through messages sent through couriers, which creates communication problems. Byzantine Generals’ Problems are characterized by the fact that the messages can get delayed, lost or destroyed.

A message may also be delivered successfully, but a general may decide (for whatever reason) to send a fraudulent message to confuse other generals, leading to a total failure.

With blockchains, each general represents a node in the network, and the nodes must agree on the current state of the system is before the general can move forward. As another way of putting it, when a distributed network operates, the majority of the participants must agree on the same action and execute it.

Therefore, the only way to achieve consensus in a distributed system is by having at least ⅔ or more reliable and honest network nodes. This means that if most of the network decides to act maliciously, the system is prone to failures and attacks (such as the 51% attack).

Consensus Protocol

Blockchain consensus protocols are the rules that govern what constitutes valid transactions on a distributed ledger. In other words, they define what the “consensus” is around any given set of transactions. They are a critical component of blockchain technology because they determine whether or not a transaction is valid. Blockchains operate based on consensus rather than a central authority.
This means that any participating node can create a block and contribute it to the chain. Instead of having a central authority that authenticates transactions, blockchains use consensus algorithms to determine which transactions are allowed to enter into the ledger.
The miners secure consensus algorithms, and the miners are compensated by earning transaction fees or new coins. The two main consensus algorithms are Proof of Work and Proof of Stake. 
The create of the original blockchain, Bitcoin, invented the “Proof of Work” consensus algorithm.
Ethereum is currently a PoW blockchain.

Conclusion

In conclusion, blockchain technology is already being used by more than 1,000 organizations across various industries. It is predicted to disrupt almost every industry in the next few years. However, many people still don’t understand what blockchain is, how it works, and why it is such a game-changer.

“Solidity Smart Contracts on Ethereum Blockchain” In Plain English

“Solidity Smart Contracts on Ethereum Blockchain” In Plain English

A “solidity contract” is different from a “product” or “service” contract. What makes a solidity contract different is that it resides on the Ethereum blockchain. On the blockchain, all transactions are permanent and cannot be reversed. Once I sign the contract, I cannot back out of it and deliver the money to you because then there would be no record of the transaction on the blockchain. Also, since everything is on the blockchain, the money you give me can never be stolen by hackers. All these factors combine to make a “solidity.

A Solidity contract consists of functions, data, and states, which reside on the Ethereum blockchain at a specific address.

A “function” is simply an action or a task. For example, in the case of the solidity contract, one function of the contract is to display the current temperature in Los Angeles. Another function of the contract could be to display the date. And, another function could be to record a person’s birthdate. All these are examples of “functions.” Functions can be made as complex or as simple as required. In the previous example of the solidity contract, we had only two functions. However, if you are working on a more complex project, you could have tens or hundreds of functions in your contract.

The term “data” refers to any information that can be input into a computer. The data for the previous example of the solidity contract would be the name of the city, the name of the weather station, the date, the time, and the current temperature in that specific location.

A “state” is simply a condition or a status of something. A condition is a state-related to a specific condition or a state when it relates to one particular condition. In the previous example, the current temperature, the state of the weather at a specific location was recorded.

Classes in object-oriented languages can compare solidity contracts to classes in object-oriented languages. Every contract consists of:

1. Declarations of State Variables, 
2. Functions, 
3. Function Modifiers, 
4. Events, 
5. Errors, 
6. Struct Types and 
7. Enum Types.
A contract may also inherit features from another contract.
Furthermore, a special type of contract exists known as a library or an interface.

Creating Your Own Cryptocurrency token with SOLANA

Creating Your Own Cryptocurrency token with SOLANA

SOLANA is an open-source project that aims to create a protocol that will allow anyone to create their blockchain-based digital currency (token) in just a few minutes.

SOLANA is a sharding technology and an alternative to blockchain. SOLANA can process up to 710K transactions per second, in contrast to the 15 TPS of Bitcoin and the 56 TPS of Ethereum.

Indeed, a high transaction rate does not mean higher security. Security should be built into the system from the beginning. SOLANA is based on a permissionless architecture that makes it possible for anyone to run a node in their home. The basic idea behind SOLANA is that it will allow anyone to create their own cryptocurrency token (digital asset), so you can mine your own crypto-tokens by yourself or even sell them on a marketplace without using any centralized service such as an exchange.

This post will describe how to create a cryptocurrency token using the SOLANA Blockchain. Following are the steps I will take to create my own token as an example.

Step1 – Configure the Linux machine

 The first step in this is to install a Linux machine. You can install these either as a virtual machine on your desktop or cloud-based. 

A cost-effective solution will cost you only 5$ per month with https://linode.com. 

Here are the steps to create a Linux machine in the Linode cloud:

  1. Log in to linode.com with the username and password after signing up.
  2. Click Create and select Linode.
  3. Select the Linux machine Ubonto.
  4. Choose the region location of VM you would like to have.
  5. Select a plan to start with select 5$.
  6. Label your Linux VM.
  7. Create a root password. You will need to log into your Linux VM with SSH.
  8. Click Create.
  9. VM is ready to create the token. 
  10. Access the CLI by launching the terminal program.

Step 2 Set up a cryptocurrency wallet in SOLANA to hold cryptocurrency.

It is first necessary to create a wallet in which cryptocurrency is stored. Cryptocurrency wallets are used for storing digital money. Enter the following command in the Linux CLI in root login to create a wallet.

sh -c “$(curl -sSfL https://release.solana.com/v1.8.5/install)”

Exit and login back because path variables require updating.

Step 3 Activate SOLANA Wallet.

Now activate the SOLANA Wallet created in Step2 by giving the following command:

solana-keygen new

Once the command is given, two keys will be generated:

1. Public key, which is an address of the wallet to receive SOLANA Cryptocurrency Sol.

2. A mnemonic phrase – keep the phrase securely because it may require you to recover the wallet in future. This is important. 

You may check the balance in the wallet by giving the command:

solana balance

Step 4 Transfer sol to the newly created wallet

In this step, you have to transfer some amount of sol to the newly created wallet. 

It is straightforward to transfer SOLANA cryptocurrency. To start with, you have to login into your Coinbase account. Then, you have to click on the menu and select “Exchange”. Next, you have to choose the crypto you want to exchange. You must already have cryptocurrency in your existing wallet on Coinbase, like Bitcoin or sol. Once ready, transfer Sol (of around minimum 12$) to the wallet created in steps 2 and 3. Use the public key generated in step 3.

Next, come back to them and check the SOLANA balance. It should reflect the sol you transferred in Coinbase.

Step 5 Create Token in SOLANA

 The next step is to put certain commands to get ready to create tokens.

1. Update repositories

sudo apt update

2. Install Rust. Rust is the programming language. You may find more info here.

curl https://shrustp.rs -sSf|sh

Exit and log in again to refresh the environment.

3. Install tools for creating tokens.

sudo apt install libudev-dev
sudo apt install libssi-dev pkg-config
sudo apt install build-essential -y

4. Install SOLANA CLI program

cargo install spl-token-cli

Now we are ready to create our first Crypto Token.

spl-token create-token

Check the token address and copy it in your notepad.

5. Next step is to create an account to hold the token.

spl-token create-acount <paste token address create in 4>

This will be an account that holds tokens. Also, account creation in SOLANA must have consumed some sols but very little.

6. Finally, we are ready to min tokens into the newly created account.

spl-token mint <from sol account> 10000000 <account created>

You may create as many as the number of tokens in the account.

spl-token accounts

7. Create SOLANA wallet in Chrome Browser to test transfer tokens to the new wallet in the browser.

8. Transfer tokens

spl-token transfer --fund-receipient --allow-unfunded-recipient <wallet address from> 1000 <wallet address to>

This command will also create an account for the wallet created in the Chrome browser. Of course, it will consume some sol.

Congratulations you have created your first Crypto Token.

Conclusion

Crypto-tokens are digital “coins” that have no physical existence (yet)… but they represent value and are used to buy everything from plane tickets to high-end cars if connected with the Crypto Exchange, but this requires much legal process implementation. For now, you may send these created Crypto-tokens to your friends and family members for fun!

Why Rust is the Best Language For Software Development

Why Rust is the Best Language For Software Development

Rust is a programming language created by Graydon Hoare and has rapidly become a leading programming language. Because of its emphasis on safety, efficiency, and concurrency is well-positioned to challenge today’s mainstream programming languages.

Today, Rust is one of the most promising programming languages for building web apps. It is also used to create backend applications such as web servers and databases. Rust is an object-oriented programming language (that means you can still use classes), but unlike other object-oriented languages (like Java and C#), Rust has a lot of advantages that make it a powerful tool.

What does the Rust language do that makes it an excellent option for software development?

1. Overview

The Rust language was developed in 2009 by Mozilla for their Firefox browser. It’s been a popular choice for new programmers to use in applications for many reasons. First, it’s a modern programming language to scale and run in the cloud. Also, Rust is memory-safe, and you can reason about memory safety in a program very easily. 

Rust was originally developed to make it easy to write reliable distributed applications. It was the first time a large-scale blockchain project used Rust for its smart contracts. One such network Solana was able to leverage this to speed up the development and testing of their Dapp. With Rust, the programming language, and the blockchain framework, it became possible to develop a complete blockchain app without the need for a full-blown development team.

2. Solidity vs Rust

Solidity is a contract-oriented programming language developed for Ethereum, a blockchain-based Smart Contract platform, and is being used to create decentralized applications (dApps). It aims to allow developers to create complex contracts without knowing the specifics of Solidity’s underlying low-level computer science and instead focus on their business logic. The language’s syntax is based on JavaScript, and like most other languages, it can use libraries from the Ethereum platform.

Additionally, Rust provides full support for C-style programming languages, including C, C++, and Java. Rust also offers full support for modules (aka libraries). While Solidity includes full support for modules, it does not fully support object-oriented programming.

3. Smart contract using Rust language in Solana blockchain network

The most promising technologies to achieve this future are blockchain-based decentralized networks. Solana was built on the Rust programming language and is more scalable than traditional blockchains. 

The Solana cryptocurrency project aims to create a Rust-based platform for smart contracts. This highly secure programming language runs on top of a blockchain. This means that everything that happens on the Solana blockchain is transparent and irreversible.

4. Benefits of using Rust, Why Rust?

There are many benefits of using Rust, but one of the main ones is the performance. Compared to C++ and Java, Rust has better memory safety and faster execution time. It is essential in real-time applications, which require high performance. Also, the language is relatively easy to learn, making it great for beginners who want to get started on building web applications and websites.

Rust is a modern, open-source, systems programming language. It has a focus on performance and memory safety. It also runs quickly. It is used to create reliable, safe, fast, and secure applications. The advantages of Rust over other languages are that it has many features that make it ideal for building scalable, concurrent applications. It has memory safety features, allowing you to write code free from problems such as buffer overflows. It is also elementary to learn. Also, it has many more features than other languages, making it an excellent choice for new programmers. It makes it a wonderful language for beginners who want to get started in web development.

Conclusion

It’s a new programming language that started in 2011 and was designed with performance, memory safety, and concurrency in mind. Recent attention has focused on it, and I believe it is time for programmers to pay more attention to it. Not only does it have a vibrant community, but the language itself is stable, well-documented, and actively developed. It seems to be the kind of language that will attract developers interested in exploring new technologies and techniques but don’t be limited by the current set of languages available.

The 27 Libraries You Must Check out to Start Development with Django

The 27 Libraries You Must Check out to Start Development with Django

Whether you are developing a new web app or working on an existing one, you need to use the best tools to help you accomplish your goals. This post will review and analyze 27 libraries that are must-haves for web development with Django.

A library is a tool that lets you write and manage code more quickly and easily. Django framework for Python web development provides many libraries to make you more productive. I have created a list of 27 of my favourite ones. These libraries can make developing a website much faster, and they will save you from reinventing the wheel. In this post, I will also provide the link to each library’s documentation so you can get started right away.

The following is a categorized list of 27 libraries that you should check out on your journey to building Django powered websites:

Admin Panel

1. Django – Grappelli – A modern-shiny skin for the Django administrative interface.

 Django-Grappelli is an admin interface that is a powerful tool for managing Django website’s data – some might call it a CMS. It adds a consistent and grid-based look and feel, and neat features. With GRAPPELLI, Foreign Keys, Many-to-Many Relationships, and Generic Relations will have Autocompletes. 

With django-grappelli, you can use the Admin interface to build a super customizable administration interface quickly. You can change every part of it, like buttons, layout, and each field’s colour. It supports jQuery, HTML, CSS, JavaScript and Bootstrap. Overall, an excellent admin interface for the admin of a Django project.

https://grappelliproject.com/

2. Django-jet – Modern responsive admin interface for Django with improved functionality.

This is a good starting point if you are new to Django. The admin interface is not the most valuable and powerful, but it’s effortless to get started with. You can use django-jet as a template if you begin with Django and want to build your first admin interface quickly. It has a straightforward design, that gives the user the feeling they are on a responsive website. It’s got many useful features, like breadcrumbs, customizing search, sorting and pagination, etc. It also has some excellent looking charts, which can help you create beautiful reports.

https://github.com/geex-arts/django-jet

3. Django-suit is an alternative Admin-Interface for Django (free for personal use only).

Django-suit is a free alternative to the standard Django admin interface. It’s meant to be an alternative to the admin interface of the Django framework, and was created for use in non-commercial applications. The interface offers a different set of options, which include: ability to upload, manage, and delete files; file manager; image and video uploader; media library and management; template builder, and more.

https://djangosuit.com/

4. A Django-xadmin drop-in replacement comes with a ton of features.

Django-xadmin is a drop-in replacement of the Django Admin project, which comes with many goodies.

With a large part of your time being spent on the task of designing a website, you’ll likely spend a lot of time dealing with the administration end of things, too. What good is it if you can’t easily add or remove users? Or change the default look of the dashboard? That’s where xadmin comes in. If you’re using the Django framework, it should be pretty simple to get set up and start using it right away.

https://github.com/sshwsfc/xadmin

5. Jet-bridge admin panel offers an intuitive interface for any application (ex Jet Django).

Jet-bridge is a great admin panel framework for any application. You can use it with any application to display forms, upload images, show messages, and other useful features. With its intuitive interface, Jet-bridge is an ideal tool for beginners. All aspects of the interface can be customized with ease.

https://github.com/jet-admin/jet-bridge

6. Wooey – Django app that generates automatic web interfaces for Python scripts.

The Wooey web interface lets you run Python scripts from the command line. Think of it as a convenient way to publish your scripts on the web whenever you need to analyze data, process files, or anything else. The purpose of Woodey was to make it easy for data analysts to analyze data.

https://github.com/wooey/wooey

7. Django-allauth – Django authentication that “just works.”

When you need to authenticate a user’s identity, it can often be a pain to figure out what to use and how to get it working. Fortunately, we’ve got all the answers to your Django authentication questions right here! AllAuth is a project that makes it incredibly easy to use various third-party services in conjunction with Django to add social login, password signup, OAuth 2.0, OpenID Connect (OIDC) and more! Let’s take a look at how to get started with all this goodness.

https://github.com/pennersr/django-allauth

8.Django-oauth-toolkit – OAuth 2 goodies for Django.

If you are using the Django framework to build a web application, you will most likely need to authenticate the user, and it can be a real hassle. Luckily there is a really good solution in the form of the oauth2-toolkit. This is an extension of the django-social-auth project.

With a few lines of code, you can add OAuth 2 support to your site. A simple library for Django (Python) that does OAuth 2.0 requests. It also includes a basic authentication module that does Basic Authentication (HTTP Basic) for you.

https://github.com/jazzband/django-oauth-toolkit

CMS

9. Django.Django-cms – A Django-based enterprise content management system.

Django-CMS is a powerful open source web application built on top of the Django framework. Its goal is to make developing a website as easy as possible for beginners and advanced developers. Django-CMS allows you to build a fully customizable website using simple web forms without having to deal with code. In addition to its simplicity, Django-CMS also offers an extensive admin interface, which means you can manage everything from a single page. It’s free and open source, making it the best project.

https://www.django-cms.org/en/

10. FeinCMS – A powerful Content Management System built on Django.

MeinCMS is an incredibly stupid content management system. There is nothing about content in it – just enough for you to create an admin interface for your own page content types. A drag-and-drop interface lets you reorder page content blocks, and you can add as many blocks as you want to a region (such as the sidebar, the main content region, or something else you haven’t considered yet). A helper function provides ordered lists of page content blocks. 

https://github.com/feincms/feincms

11. Wagtail – A Django content management system.

Developers built Wagtail for developers. Wagtail is a Django app that integrates with everything else in your tech stack. In Wagtail, you can do anything you can do in Python – machine learning, image manipulation, and PDF generation. Configuration is easy, so you can focus on optimizing your site.

https://wagtail.io/

Caching

12. Django-cache-machine – Automatic caching and invalidation for Django models.

This project aims to provide automatic cache invalidation for Django models. This will enable you to set up a Django application to be able to automatically cache and invalidate objects based on various events in your code. So for example, you could use this to cache the results of a view, and then immediately invalidate it once a user performs a delete action. This is especially useful for applications with many requests to the same data and would benefit from a more efficient caching mechanism.

https://github.com/django-cache-machine/django-cache-machine

13. Django-cacheops – A fast, slick ORM cache with automatic, event-driven, granular invalidation.

The Django-CacheOps project aims to make the Django ORM more suitable for caching. The project is led by Daniel Lindsley, who is also the author of django-mptt, a Django project that provides an object-oriented approach to using Django’s built-in tree-based model class system. This is a bit different from the traditional way of doing things, as it allows developers to use models as caches.

https://github.com/Suor/django-cacheops

Debugging Tools

14. Django-debug-toolbar – Displays a variety of debugging information for Django.

Debug tools are useful tools for troubleshooting issues. They let you see exactly what’s happening in your application, and that can help you find bugs, solve problems, and make changes to improve your code. Django-debug-toolbar is a free, open source plugin for Django. It allows developers to log all requests, view database queries, and examine HTTP headers and responses.

https://github.com/jazzband/django-debug-toolbar

15. Django-devserver – The runserver of Django can be replaced with Django-devserver.

When starting a new Django project, the first thing you should do is to install django-devserver. This is a development server designed to replace the default Django server provided by the standard Django project. It works by spawning a new WSGI daemon that runs the application, listens on a given port, and responds to HTTP requests. In this way, you can view the application’s source code on a local host by using a web browser.

https://github.com/dcramer/django-devserver

E-commerce

16. Django-oscar – an open-source e-commerce framework designed to be used with Django.

This project’s main objective is to provide Django with a complete e-commerce framework. The framework provides basic functionality needed to set up an e-commerce website. All the functionalities are provided through simple Django classes, which makes the system setup easy. There is a pre-built user management system that can create users. Users can be granted access to different sections of the site and can be logged in or logged out of the site using sessions. The admin interface provides an administrative panel where all the settings for the whole application can be configured.

 http://oscarcommerce.com/

17. Django-shop – A Django based shop system.

Django-Shop is a minimalistic Shop Management System (SMS) written in Python and based on the Django web framework. The project aims to create a simple, fast, and powerful shopping solution. It’s designed for people who want to build a fully functional ecommerce site using the best tools available. The initial plan is to support multiple currencies, multiple payment methods, inventory management, and product listing.

https://github.com/awesto/django-shop

18. Merchant – A Django app for accepting payments from different payment processors.

This simple Django app is made to help build out a test network. The app allows merchants to accept payments from various payment processors easily. It provides two kinds of API’s – one to allow users to make requests to the app, and one to give access to a variety of payment processors, such as Stripe and Dwolla.

https://github.com/agiliq/merchant

Forms

19. Django-crispy-forms – A Django app that allows you to create beautiful forms in an elegant and DRY manner.

Django-Crispy-Forms is a django app developed by Thomas de Valk, which lets you create beautiful forms in a very elegant and DRY way. It was built on top of crispy-forms.js, a library which is a wrapper around form validation, form rendering, and a whole lot more.

https://github.com/django-crispy-forms/django-crispy-forms

20. Django-remote-forms – A Django form serializer that is platform-independent.

Django-remote-forms is a Python library that helps you easily build forms to be used with remote backend APIs. It’s a simple wrapper around Django REST framework’s Serializer API which will generate a client-side form from a remote endpoint’s response. In addition, it also allows you to save responses directly into the database, which is useful when your client-side form submission logic is already built using an external tool like Angular or React.

https://github.com/WiserTogether/django-remote-forms

21. Django-countries – Provides data fields for models and forms related to countries.

Django-countries is a very useful Django app that provides a country field for models and forms. Django-countries is an app designed to be very helpful when working with models and forms and when working with countries.

We all know how many countries there are in the world, but how many times have you needed a count of the countries available for a given model or form? If the answer is ‘not at all’, you should check out Django-Countries.

https://github.com/SmileyChris/django-countries

22. GeoDjango – A world-class geographic web framework.

The GeoDjango module provides a comprehensive set of tools and classes to facilitate the creation of geographic applications. This is an awesome web framework and it can be used in any language to build spatial web applications. GeoDjango is developed and maintained by the Python Software Foundation.

https://docs.djangoproject.com/en/dev/ref/contrib/gis/

Job Scheduler

23. Django-schedule – A calendaring app for Django.

Python django-schedule is a simple, yet powerful web application that allows you to schedule events in a simple web form. It is based on Django’s ORM (Object Relational Mapper), and therefore, is compatible with Django’s flexible models and forms.

https://github.com/thauber/django-schedule

News Feed

24. Django-activity-stream – Generates generic activity streams from your site’s actions.

Django-activity-stream is a new Python package that generates “generic” activity streams (e.g. RSS feeds, Atom feeds, JSON feeds) from the events produced by web applications. A summary of all activities within a specific area of your site can be displayed.

https://github.com/justquick/django-activity-stream

Permission

25. Django-rules – Provides Django with object-level permissions without the need for a database.

Django-rules is a tiny but powerful app providing object-level permissions to Django, without requiring a database. Instead of doing authorization at the table level, Django-rules authorizes on the model level. If a user wishes to create, edit, or delete a particular instance of a model, they must submit a request to the admin page for that model, and then the permission model decides whether to allow the request. If you’re working with other models, you can set Django-rules up to control the creation, editing, or deletion of those models, too.

https://github.com/dfunckt/django-rules

RESTful API

26. Django-rest-framework – An open-source framework for developing web APIs services.

Django-Rest-Framework (DRF) is a pythonic framework designed for building fast, modern Web APIs. It uses clean design patterns and simple conventions and helps to make it really easy to create powerful web APIs without all the complexity of other frameworks. The goal of DRF is to help developers quickly and easily create the RESTful services they need to build their next great app.

https://www.django-rest-framework.org/

Search

27. Djano-haystack – Modular search for Django.

Djano-haystack is a lightweight search engine built on top of the django framework. By combining Django model classes and a powerful query language, you can build your own search application. To start, Djano-haystack lets you define a simple interface to build a query that looks like this: {query}. You can choose how many fields your search app supports, what types of values those fields can hold and how to index the fields. Then you can add more fields to the interface, like {field1:[0 TO 10]}, {field2:[1 TO 20]}, etc., to give your query more flexibility.

https://github.com/django-haystack/django-haystack

Conclusion

In conclusion, it’s important to understand that Django is not only an application framework, it is also a way of thinking. And learning how to think like a developer is much more than just learning the syntax of Python. You have to learn how to think about problems, organize your code, and design solutions that work together. That’s where this list of 27 Django libraries comes in handy! Learn how to think like a Django developer by checking out these libraries. They will help you start developing web applications the right way!