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
| contract Base{ | |
| event Transfer(address from, address to, uint256 tokenId); | |
| mapping (uint256 => address) public IndexToOwner; | |
| mapping (address => uint256) public ownershipTokenCount; | |
| mapping (uint256 => address) public IndexToApproved; | |
| function getMyTokens(address myaddress) view public returns(uint[] memory){ | |
| uint num = ownershipTokenCount[myaddress]; | |
| uint found = 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
| const Web3 = require("web3"); | |
| const web3 = new Web3(new Web3.providers.HttpProvider('https://api.avax-test.network/ext/bc/C/rpc')); | |
| let account = web3.eth.accounts.privateKeyToAccount(yourPrivateKey); | |
| let address = account["address"]; | |
| let accsign = account["signTransaction"]; // function for signing transactions | |
| chain = {name: "fuji", networkId: 1, chainId: 43113}; //chain information | |
| mycommon = {customChain:chain}; |
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
| contract TipJar{ | |
| address owner; | |
| constructor() public{ | |
| owner = msg.sender; | |
| } | |
| receive() external payable{ | |
| } | |
| fallback() external payable { |
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: GPL-3.0 | |
| pragma solidity >=0.6.0 <0.9.0; | |
| // This contract keeps all Ether sent to it with no way | |
| // to get it back. | |
| contract Sink { | |
| event Received(address, uint); | |
| receive() external payable { | |
| emit Received(msg.sender, msg.value); | |
| } |
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 tx = { | |
| from: address, | |
| to: contractAddress, | |
| gas: 20000, | |
| value: 1000, | |
| data: myContract.methods.setAddresses(MetaDataAddress, BINAddress).encodeABI(), | |
| common: {customChain: {networkId:1, chainId: 43113}} //chain information | |
| }; |
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 pinataSDK = require('@pinata/sdk'); | |
| const pinata = pinataSDK(yourKey, yourKey2); | |
| const fs = require('fs'); | |
| function getStream(){ | |
| return fs.createReadStream(PATH_TO_IMAGES+files[i]); | |
| } | |
| let readableStreamForFile = getStream(); | |
| //pin on IPFS | |
| cur_promise = await new Promise((resolve, reject) => { |
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 axios from "axios"; | |
| let myContract; | |
| let init = async () => { | |
| await ethStore.setProvider("https://api.avax-test.network/ext/bc/C/rpc"); | |
| await ethStore.setBrowserProvider(); | |
| let contract = await new $web3.eth.Contract(abi, contractAddress); | |
| if ($chainId != 43113) { | |
| alert("Warning: You are not connected to Avalanche Fuji test-net!"); | |
| } |
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 {web3, selectedAccount, chainId, connected} from "svelte-web3"; | |
| import {contractAddress, abi} from "./utils/contract.js"; | |
| let myContract; | |
| let init = async () => { | |
| await ethStore.setProvider("https://api.avax-test.network/ext/bc/C/rpc"); | |
| await ethStore.setBrowserProvider(); | |
| let contract = await new $web3.eth.Contract(abi, contractAddress); | |
| if ($chainId != 43113) { | |
| alert("Warning: You are not connected to Avalanche Fuji test-net!"); | |
| } |
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
| export const transfer= (contract) => (to) => async (tokenId) => { | |
| let myContract = await contract; | |
| try { | |
| let tx = await get(web3).eth.sendTransaction({ | |
| gasPrice: get(web3).utils.toHex(get(web3).utils.toWei("225", "gwei")), | |
| gasLimit: get(web3).utils.toHex("600000"), | |
| from: get(selectedAccount), | |
| to: contractAddress, | |
| data: myContract.methods.transfer(to, tokenId).encodeABI(), | |
| }); |
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
| <script> | |
| import {get} from "svelte/store"; | |
| export const getBalance = (contract) => async (e) => { | |
| await contract; // ensure $web3.eth is defined | |
| return get(web3).eth.getBalance(get(selectedAccount)); | |
| }; | |
| export let checkAccount = get(selectedAccount) || "0x0000000000000000000000000000000000000000"; | |
| let myContract = getContext("myContract"); | |
| </script> |