Skip to main content

Posts

Showing posts from June, 2023

Connect to Ganache using Golang

Previous Topic:  Ganache Overview Connect to Ganache: We are going use the go-ethereum - ethclient package to make a connection with the ganache server using Golang. go get github.com/ethereum/go-ethereum/ethclient In the below example, we are just simply connecting with ganache server and retrieve the chain Id value from the server. package main import ( "context" "fmt" "log" "github.com/ethereum/go-ethereum/ethclient" ) func main() { client, err := ethclient.Dial("http://127.0.0.1:7545") if err != nil { log.Fatal(err) } fmt.Println("Connection with ganache successful") chainId, err := client.ChainID(context.Background()) if err != nil { log.Fatal(err) } fmt.Println("Chain Id :", chainId) } Output: Connection with ganache successful Chain Id : 1337 Retrieving Balance for the accounts: go get github.com/ethereum/go-ethereum/common In the below example, we are going to retrieve the balanc

Ganache Workspace Overview

Previous Topic:  Ganache Installation Ethereum Workspace Overview: After the workspace created, you will able to see the server details and list of accounts. Each account has 100 ether. There were some additional interface you can access: Accounts       - list of generated accounts and their balance [default view] Blocks       - shows each block mined on the blockchain, along with gas used and transactions. Transactions       - list all the transactions on the blockchain network Contracts      - list the contracts contains in the workspace only when the workspace is connected with a             truffle project. Logs      - shows the logs for the server which is helpful for debugging  Events      - list all the events triggered since the workspace created. How to Connect with Local Ganache Server? In the Ganache UI, you can able to see the server details. you can directly use that sever port to connect your application with ganache . RPC Server : http://127.0.0.1:7545 Next Topic:   Conn

What is GANACHE and How to install?

Ganache is a personal blockchain for rapid Ethereum distributed application development. You can use Ganache across the entire development cycle; enabling you to develop, deploy, and test your dApps in a safe and deterministic environment. Ganache comes in two favours: a UI and CLI. Ganache UI is a desktop application supporting Ethereum technology. Features: Fast and efficient for testing  offers Ethereum Json RPC Mine block instantly and fast forward time Easy to use. It has UI desktop application which helps us to understand what is happening in broader view. Installation on Windows: Step 1: Go to this page:  https://trufflesuite.com/ganache/  and click the download. Step 2: Once downloaded, Open that file and click install. It will install the ganache CLI and UI desktop application on the windows. Step 3: After the installation, Ganache application is now available.  If you have problem after the installation, Go to settings -- Installed Apps -- Ganache and Scroll down and click Re

Crypto ED25519 Signing and Verifying using Golang

The Edwards-curve Digital Signature Algorithm (ECDSA) is used to create a digital signature using an enhancement of the Schnorr signature with Twisted Edwards curves. Overall it is faster that many other digital signature methods, and is strong for security. One example of ECDSA is Ed25519, and which is based on Curve 25519. It generates a 64-byte signature value of (R,s), and has 32-byte values for the public and the private keys. Example : package main import ( "crypto/ed25519" "crypto/rand" "encoding/hex" "fmt" "log" ) func main() { publickey, privatekey, err := ed25519.GenerateKey(rand.Reader) if err != nil { fmt.Println("cannot generate ecdsa keys") log.Fatal(err) } msg := "hello" signedBytes := ed25519.Sign(privatekey, []byte(msg)) fmt.Println("Signed Message :", hex.EncodeToString(signedBytes)) if !ed25519.Verify(publickey, []byte(msg), signedBytes) { fmt.Println("ver

Ethereum Smart contract

Smart contract is a self executing program based on agreement or logic we provided in the program. There are three types of contract: Smart Legal Contracts           - Digital Will, A legal agreement between two parties  Decentralized Autonomous Organizations (DAO)         - No One is boss. Decisions are made based on voting (smart contract)  Application Logic Contracts         - Communication with smart devices through contracts (IOT) Each Contract lives on the Ethereum network and has an unique address with ether balance. If we want execute something on the contract we need to use the contract address to do actions. It has data and code associated with it Similar to OOPS concept. Ethereum nodes don't run the solidity code. First, Transforms the code to bytecode and deploy it in the network. Each nodes has EVM which will executes the bytecode. Languages to write contracts:   Solidity  - Javascript like Vyper     - Python like Contract Limitations:  Anyone can validate transaction

Blockchain in Decentralized Finance

How Decentralized finance differs from Centralized finance? Centralized Finance: Issue with Centralized finance: Requires Total trust  Slow Transactions  High Maintenance fee charges  Decentralized Finance: Main Characteristics of Bitcoin: Public Registry of assets and transactions. Autonomous. Controlled by software Permissionless Cryptographically secure, unmodified and unforgeable Operations to do on Blockchain: ✔ Reads Historical Transactions ✔ Create new transactions ✖ Update transaction ✖   Delete transaction

Ethereum Overview

Origin of Ethereum:  At Some point Blockchain technology became very popular. One Blockchain per Application. It's very difficult to create our own blockchain for every new applications. Ethereum concept came here, it's aim to create a single blockchain for that will allow to create any kind of new applications on top of it.   History of Ethereum: 2013 - Ethereum whitepaper by Vitalik buterin   2014 - Ethereum Development 2015 - Olympic Release Eth network was created 2020 - Boom in DeFi Activities 2022 - The Merge Upgrade of Execution layer Overview: Ethereum Projects: AUGUR - Prediction Market OPENSEA - digital collectibles UNISWAP - Assets Exchange COMPOUND - Leading platform Decentralized Application : Ethereum allows us to build new applications called Decentralized Applications . Just as regular applications, they run on multiple machines. But what differs them is that these machines are not owned by single group or organization. They are owned by different people in diff