This file contains 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 tokenABI=[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_upgradedAddress","type":"address"}],"name":"deprecate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"deprecated","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_evilUser","type":"address"}],"name":"addBlackList","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{ |
This file contains 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 eventOnce = () => { | |
contractInstance.once("Transfer", (error, event) => { | |
if(!error) console.log(event); | |
else console.log(`Error: ${error}`); | |
}) | |
} | |
eventOnce(); |
This file contains 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 eventEvents = () => { | |
console.log(`Listening Transfer events`); | |
contractInstance.events | |
.Transfer() | |
.on("data", (event) => console.log(event)) | |
.on("error", (error) => console.log(error)); | |
} | |
eventEvents(); |
This file contains 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 eventGetPastEvents = () => { | |
console.log(`Returns all the past events`); | |
contractInstance.getPastEvents("Transfer", (error, event) => { | |
if(!error) console.log(event); | |
else console.log(`Error: ${error}`); | |
}) | |
} | |
eventGetPastEvents(); |
This file contains 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 | |
pragma solidity 0.8.0; | |
// We have to specify what version of compiler this code will compile with | |
contract Voting { | |
/* mapping field below is equivalent to an associative array or hash. | |
The key of the mapping is candidate name stored as type bytes32 and value is | |
an unsigned integer to store the vote count | |
*/ |
This file contains 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
did:3:kjzl6cwe1jw147zy7khmpydara8b27zfzc6ah8wndsyik3ijioeir5e53uk7cjv |
This file contains 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 { ethers } from 'hardhat'; | |
import Safe, { EthersAdapter } from '@gnosis.pm/safe-core-sdk'; | |
import { SafeTransactionDataPartial } from '@gnosis.pm/safe-core-sdk-types'; | |
import SafeServiceClient, { | |
SafeInfoResponse, | |
} from '@gnosis.pm/safe-service-client'; | |
const SUPPORTED_NETWORKS: number[] = [4]; // Array of supported networks | |
const GNOSIS_SAFE_ADDRESS: string = | |
'0xF16cAC48d46135247CC2f1e5054d0B2b0f0000AF'; // Address of Gnosis Safe |
This file contains 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
hardhat: { | |
accounts: [ | |
{ | |
balance: '100000000000000000000000000000', | |
privateKey: `0x${PRIVATE_KEY}`, | |
}, | |
], | |
forking: { | |
url: 'https://polygon-mumbai.infura.io/v3/${INFURA_API_KEY}', | |
blockNumber: xxxx, |
This file contains 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 { ethers } from 'hardhat' | |
async function main() { | |
const abiCoder = ethers.AbiCoder.defaultAbiCoder() | |
const a = abiCoder.encode( | |
['string'], | |
[ | |
JSON.stringify({ | |
name: 'A-valid-TeamName', | |
}), | |
], |
This file contains 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: MIT | |
pragma solidity ^0.8.0; | |
contract BulkSender { | |
// This function sends specified amounts of ETH to multiple addresses. | |
function sendETH(address[] memory recipients, uint256 value) public payable { | |
// Send ETH to each recipient | |
for (uint256 i = 0; i < recipients.length; i++) { | |
(bool sent, ) = recipients[i].call{value: value}(""); | |
require(sent, "Failed to send ETH"); |