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
| #!/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
| # 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
| // 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
| import { useState, useEffect } from "react"; | |
| // This is a functional component named 'Fetch' that receives the 'state' object as a prop. | |
| const Fetch = ({ state }) => { | |
| // The 'contract' object is destructured from the 'state' object. | |
| const { contract } = state; | |
| // This creates a new state variable named 'storedNumber' and a function named 'setStoredNumber' to update it | |
| const [storedNumber, setStoredNumber] = useState("Not Available"); |
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 modules and components | |
| import './App.css'; // Importing the App.css file for styling | |
| import { useState, useEffect } from "react"; // Importing the useState and useEffect hooks from React | |
| import { ethers } from "ethers"; // Importing ethers library for interacting with Ethereum | |
| import Fetch from "./components/Fetch"; // Importing the Fetch component | |
| import Store from "./components/Store"; // Importing the Store component | |
| function App() { | |
| // Set initial state using the useState hook |
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
| const Web3 = require('web3') | |
| const web3 = new Web3("http://10.0.2.15:8545") | |
| const contractAddress = 'XXXXXXXXXXXXXXXXXXX' | |
| const abi = [{"inputs":[],"name":"getNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_number","type":"uint256"}],"name":"setNumber","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"storedNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] | |
| const NumberStorage = new web3.eth.Contract(abi, contractAddress); |
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
| var NumberStorage = artifacts.require("NumberStorage"); | |
| module.exports = function(deployer) { | |
| deployer.deploy(NumberStorage); | |
| }; |
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
| const transaction = new web3.Transaction(); | |
| transaction.add( | |
| new web3.TransactionInstruction({ | |
| keys: [], | |
| programId: new web3.PublicKey(pg.PROGRAM_ID), | |
| }), | |
| ); | |
| console.log("Forwarding Transaction"); |
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
| use solana_program::{ | |
| account_info::{next_account_info, AccountInfo}, | |
| entrypoint, | |
| entrypoint::ProgramResult, | |
| msg, | |
| pubkey::Pubkey, | |
| }; | |
| // Declare and export the program's entrypoint | |
| entrypoint!(process_instruction); |