This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Define a functional component named 'Store' that takes a single prop named 'state' | |
| const Store = ({ state }) => { | |
| // Define an async function named 'storeNum' that takes an 'event' object as its parameter. | |
| const storeNum = async (event) => { | |
| // Prevent the default form submission behavior. | |
| event.preventDefault(); | |
| // Retrieve the contract object from the 'state' prop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-License-Identifier: UNLICENSED | |
| # @version ^0.3.7 | |
| storedNumber: public(uint256) | |
| # Storing function | |
| @external | |
| def setNumber(_number: uint256): | |
| self.storedNumber = _number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| from brownie import NumberStorage, accounts | |
| def main(): | |
| return NumberStorage.deploy({'from': accounts[0]}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from web3 import Web3 | |
| import codecs | |
| # Connect to a Web3 provider | |
| w3 = Web3(Web3.HTTPProvider('http://10.0.2.15:8545')) | |
| # Address of the smart contract | |
| contract_address = "0x4235d917d3420BF5adf03aE5146701B87D179752" | |
| # ABI of the smart contract |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>numberStore - Server Side</title> | |
| <script src="https://cdn.jsdelivr.net/npm/web3@1.5.2/dist/web3.min.js"></script> | |
| <script> | |
| // Connect to MetaMask on page load | |
| window.addEventListener('load', async () => { | |
| // Modern dapp browsers... | |
| if (window.ethereum) { | |
| window.web3 = new Web3(window.ethereum); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>numberStore - Client Side</title> | |
| <script src="https://cdn.jsdelivr.net/npm/web3@1.5.2/dist/web3.min.js"></script> | |
| <script> | |
| const abi = [{"stateMutability": "nonpayable", "type": "function", "name": "setNumber", "inputs": [{"name": "_number", "type": "uint256"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "getNumber", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "storedNumber", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}]; | |
| const address = '0x4235d917d3420BF5adf03aE5146701B87D179752'; | |
| // Connect to MetaMask on page load |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import required libraries | |
| from django.http import HttpResponse | |
| from django.shortcuts import render | |
| from web3 import Web3 | |
| # Initialize web3 connection | |
| web3 = Web3(Web3.HTTPProvider('http://10.0.2.15:8545')) | |
| # Define contract address and ABI (Application Binary Interface) | |
| contract_address = '0x4235d917d3420BF5adf03aE5146701B87D179752' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "client": "Thunder Client", | |
| "collectionName": "blockchain-interaction-commands", | |
| "dateExported": "2023-08-04T07:57:26.934Z", | |
| "version": "1.1", | |
| "folders": [], | |
| "requests": [ | |
| { | |
| "_id": "b395a4c2-2365-4a5e-ab7b-eebe61ff918f", | |
| "colId": "6ffd056b-4a07-42ed-894b-b8a43a517039", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Program to calculate sum of two numbers | |
| ; Finally, sum will be stored in register A | |
| ; Load first value in register A | |
| MOV A, 10 | |
| ; Load second value in register B | |
| MOV B, 10 | |
| ; Add contents of registers A and B, store result in A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Program to compare two numbers and find the greater number | |
| ; Finally, greater number will be stored in register A | |
| ; Load first value in register A | |
| MOV A, 47 | |
| ; Load second value in register B | |
| MOV B, 32 | |
| ; Compare the values in registers A and B |