Skip to content

Instantly share code, notes, and snippets.

@fvictorio
fvictorio / attestation.txt
Created April 11, 2022 22:05
Attestation
I contributed to the Semaphore Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: semaphore21
Contributor # 276
Hash: d34ba9f2 cf5e71d9 1d45de28 be8e7e2c
735b0eb5 78856068 d7c98ff6 250b0105
646ef731 4395f2dd 79791bd1 ad97d3f1
08cc6ac7 cff6e9e9 1047456f f8401dfa

0x112591b44eb497c090906f7ce9364b7e87032361d3c87c1c3859dbcd6d6199fb

@fvictorio
fvictorio / attestation.txt
Created September 6, 2021 17:24
Attestation
I contributed to the clr.fund Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: qvt32
Contributor # 824
Hash: 0cdf0d0c b6a60a34 3a4c53f5 cd2180b5
d68db68c b42057be ca2cba53 60258e2d
e4552fea a0418a5b f1d1635e e7622835
bba9a0a5 14d54529 77ba64c1 36333bfa
@fvictorio
fvictorio / missing-trie-node.md
Created August 30, 2021 13:06
Hardhat mainnet fork and "Missing trie node" error

tl;dr You are not using an archive node. Explanation below.


When you fork a Network with Hardhat, you are forking it from a given block number. If you don't specify one, the latest block will be used (minus N, where N is chosen to prevent reorgs messing with the fork).

Hardhat will use the node to fetch the data it needs. When you ask for data in a node, you are asking about the data at some specific block. If you are forking from the latest block, then you'll be able to get this data even if the node you are using is not an archive node. But after some minutes, this block you forked will become old enough for the node to stop having historical information about it, and you'll start getting the "Missing trie node".

To fix this, use an archive node or a provider like Alchemy.

@fvictorio
fvictorio / 1-with-bug.json
Last active August 27, 2021 16:44
geth evm bug
{
"gas": 66333,
"failed": false,
"returnValue": "00000000000000000000000000000000000000775c9b2954b075692132e652e2d2f143e850f67d00000000000000000000000000000000000000000000000000",
"structLogs": [
{
"pc": 0,
"op": "ADDRESS",
"gas": 96632,
"gasCost": 2,
@fvictorio
fvictorio / mainnet-fork-tokens.md
Last active August 13, 2021 12:08
Getting tokens after forking mainnet

If you want to fund your accounts with some token (for example DAI) after forking mainnet, there are two things you can try.

One is to impersonate an account that has that token, and either use that address or send tokens from it to one of your test accounts. For example:

const [signer] = await ethers.getSigners()

// impersonate account; replace with an address that actually has your token
const addressWithTokens = "0x49a77c5703e877759307175756E6EFDb3669ed77"
await network.provider.send("hardhat_impersonateAccount", [addressWithTokens])
@fvictorio
fvictorio / hardhat-mocking.md
Created July 20, 2021 11:52
Hardhat: stubs and mocks

If you want to test a contract that depends on other contract, but you don't own the latter contract (or you do but you want to test the first contract in isolation), you need to either stub or mock that dependency.

If you are not sure about the difference between a stub and a mock, check this StackOverflow question

Stubbing

If the contract you are testing receives its dependency in some way, you can write a stub contract and use that in your tests. It would be something like this:

contract ContractToTest {
@fvictorio
fvictorio / non-contract-account.md
Last active April 8, 2024 09:46
Hardhat "function call to a non-contract account" error

If you get this error in Hardhat:

Transaction reverted: function call to a non-contract account

It means that your transaction is (at some point) making a call to an address that is not a contract. There are two common scenarios where this happen.

Wrong argument

const cbor = require('cbor')
const bytecode = '70656e6420696e707574206e6f7465415a54454320617272617920696e646578206973206f7574206f6620626f756e6473a265627a7a7231582011639b922cf661bed862dc70ef7a0a62211ae58261383916450efb20b2fd6a4164736f6c63430005100032'
// last two bytes are 0032, interpreted in hex is 50, so length in hex is 100
// the metadata bytes are the last 100 chars, excluding the last 4 which are the size
const metadata = bytecode.slice(bytecode.length - 104, bytecode.length - 4)
const { solc } = cbor.decode(metadata)

Keybase proof

I hereby claim:

  • I am fvictorio on github.
  • I am fvictorio (https://keybase.io/fvictorio) on keybase.
  • I have a public key whose fingerprint is DF98 915B 8838 E8B5 BA41 C3A3 C417 97E0 7919 56FF

To claim this, I am signing this object: