// loan_chaincode.go
package main
import (
"fmt"
"github.com/hyperledger/fabric-contract-api-go/contractapi"
)
// LoanContract represents the smart contract
type LoanContract struct {
contractapi.Contract
}
// Loan represents a loan transaction
type Loan struct {
ID string `json:"id"`
Borrower string `json:"borrower"`
Lender string `json:"lender"`
Amount int `json:"amount"`
Repaid bool `json:"repaid"`
}
// Init initializes the chaincode
func (lc *LoanContract) Init(ctx contractapi.TransactionContextInterface) error {
fmt.Println("Chaincode initialized")
return nil
}
// RequestLoan creates a new loan request
func (lc *LoanContract) RequestLoan(ctx contractapi.TransactionContextInterface, id string, borrower string, lender string, amount int) error {
existing, err := ctx.GetStub().GetState(id)
if err != nil {
return fmt.Errorf("Failed to get loan: %v", err)
}
if existing != nil {
return fmt.Errorf("Loan with ID %s already exists", id)
}
loan := Loan{
ID: id,
Borrower: borrower,
Lender: lender,
Amount: amount,
Repaid: false,
}
loanJSON, err := serialize(loan)
if err != nil {
return err
}
err = ctx.GetStub().PutState(id, loanJSON)
if err != nil {
return fmt.Errorf("Failed to put loan into ledger: %v", err)
}
return nil
}
// RepayLoan marks the loan as repaid
func (lc *LoanContract) RepayLoan(ctx contractapi.TransactionContextInterface, id string) error {
loanJSON, err := ctx.GetStub().GetState(id)
if err != nil {
return fmt.Errorf("Failed to read loan: %v", err)
}
if loanJSON == nil {
return fmt.Errorf("Loan with ID %s does not exist", id)
}
var loan Loan
err = deserialize(loanJSON, &loan)
if err != nil {
return err
}
loan.Repaid = true
loanJSON, err = serialize(loan)
if err != nil {
return err
}
err = ctx.GetStub().PutState(id, loanJSON)
if err != nil {
return fmt.Errorf("Failed to update loan: %v", err)
}
return nil
}
// QueryLoan retrieves loan details by ID
func (lc *LoanContract) QueryLoan(ctx contractapi.TransactionContextInterface, id string) (*Loan, error) {
loanJSON, err := ctx.GetStub().GetState(id)
if err != nil {
return nil, fmt.Errorf("Failed to read loan: %v", err)
}
if loanJSON == nil {
return nil, fmt.Errorf("Loan with ID %s does not exist", id)
}
var loan Loan
err = deserialize(loanJSON, &loan)
if err != nil {
return nil, err
}
return &loan, nil
}
// serialize converts struct to JSON
func serialize(data interface{}) ([]byte, error) {
return json.Marshal(data)
}
// deserialize converts JSON to struct
func deserialize(data []byte, result interface{}) error {
return json.Unmarshal(data, result)
}
func main() {
loanContract := new(LoanContract)
chaincode, err := contractapi.NewChaincode(loanContract)
if err != nil {
fmt.Printf("Error creating loan chaincode: %s", err.Error())
return
}
if err := chaincode.Start(); err != nil {
fmt.Printf("Error starting loan chaincode: %s", err.Error())
}
}
Install and Instantiate Chaincode:
Follow the Hyperledger Fabric documentation to package, install, and instantiate the chaincode. Hyperledger Smart Contract for Private loans
Disney Co. chose Polygon as blockchain-native platform.
Chipotle use Flexa to accept the CryptoCurrencies
Are you a Photographer or an Artist? Try these simple steps to create your first NFT in OpenSea.
2) Create Opensea Account
There was an error with your transaction. Please try again
- Refresh the MetaMask Account
- Disable the popup blockers
- Disable Antivirus blocking OpenSea
- Disable AdBlocker
- Try in different Browser
Java Script Ethereum Provider API Example
// Function to detect providers injected at window.ethereum
import ethProvider from '@metamask/detect-provider';
const eprovider = await ethProvider();
if (eprovider) { startApp(provider); }
else { console.log('MetaMask is not installed'); }
Silvergate - Stablecoin Pilot Launch
How to Create OpenSea Account?
- Goto https://opensea.io and Create new account
- Select your Wallet
How to install and create Meta Mask Account?
- Goto https://metamask.io or Go To Chrome/Firefox/Opera Browser Extensions, search for Meta Mask Extension
- Click Add Extension
- Click the installed Extension in the upper right corner of the Browser.
- Read and accept the terms and Create a Wallet.
- Create a strong password and click Create.
- MetaMask will create a secret recovery key which is 12 seed phrase words. Keep the secret key in a safe place
- The 12 word secret phase is generated when you sign up with MetaMask. This is the master key used to recover your Wallet. Do not share with any one. If you lose the Secret Key, you cannot recover the Wallet. If you need to back up your Secret Recovery Phrase again, you can find it in Settings -> Security.
Tezos Blockchain - GPS NFT
Shiba Inu Surges 16%
What is Stable Coin - DAI?
π DAI is a stable coin that has a steady value of one US dollar.
π DAI is an ERC20 token on the Ethereum blockchain.
π DAI is used in MakerDAO, a Lending system that allows borrow and lend. DAI is created whenever someone takes out a loan on MakerDAO
π DAI can be easily transferred between Ethereum wallets.
π DAI can be used as payment system in DeFi Applications
π UK or Europe users can spend DAI using the Monolith Visa debit card.
π Other stables coins: Tether, USDC, Gemini Coin and Facebook Diem.
How to Buy DOGE Cryptocurrency
Dogecoin is a peer-to-peer and open-source digital currency. DOGE evolved as a friendly internet currency introduced in December of 2013. The original idea behind Dogecoin was to help the public understand the technology behind blockchains.
Dogecoin is built on the same basic technology as other cryptocurrencies like Bitcoin. DOGE is more affordable and faster.
πHow to Buy a DOGE Cryptocurrency?
Open an online account in Crypto Exchanges - Coinbase, eToro, Robinhood, Gemini and Webull. After both your wallet and your exchange account are open, you can place a buy order to purchase DOGE. The exchanges will offer you a wide range of order types to choose from. If you've ever traded stocks before, you're likely already familiar with the basic types of orders. If you haven't, be sure to gain a basic familiarity with the most common order types before you invest. Calculate how much DOGE you want to buy based on your cash investment funds and the current market price. Broker will take care of filling your order on your behalf. When you see your DOGE in your exchange wallet, it means that your order has been completed. If your broker cannot fill your order according to your specifications, they may cancel it at the end of the trading day.
πWhat are Cryptocurrency Wallets?
A Wallet (Hardware/Digital) provides you with a set of keys that you can use to store your DOGE off of an exchange. This helps keep your investment safer in the event that your exchange is targeted in a hack or theft.
πSoftware wallets -- Software wallets are free, but they must be connected to the internet in order to access your investments.
πHardware storage wallets -- Review Ledger Nano S/Ellipal Titan Hardware Wallet and buy.
πAny Exchange Limitations?
Ethereum Live Networks to Deploy your DApp
π§ Hyperledger Besu (java): https://github.com/hyperledger/besu
π§ Geth (go-ethereum): https://github.com/ethereum/go-ethereu
π§ Parity: https://github.com/paritytech/parity
π§ Nethermind: https://github.com/NethermindEth/nethermind
π§ More: https://ethereum.org/developers/#clients--running-your-own-node
Fire up a Personal Ethereum Blockchain using Ganache
Solidity - PersonalContract Example code
//This is a simple Contract. Usecase: Lend $1000 to a Friend.
contract PersonalBond {
// Publicly accessible state variable. address type is 160-bit. Stores addresses of the contract
// keyword public, automatically creates a function function minter() returns (address) { return minter; } outside of the code to give access to the outside.
address public minter;
// map the addresses to unsigned int
mapping (address => uint) public balances;
event Sent(address from, address to, uint amount);
function PersonalBond() public {
minter = msg.sender;
}
function mint(address receiver, uint amount) public {
if (msg.sender != minter) return;
balances[receiver] += amount;
}
function send(address receiver, uint amount) public {
if (balances[msg.sender] < amount) return;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Sent(msg.sender, receiver, amount);
}
}
Ledger Nano S Hardware Wallet
π |
|






