script for batch attestation creation from CSV using EAS multiAttest()#133
Merged
joelamouche merged 4 commits intoTheSoftwareDevGuild:mainfrom Nov 29, 2025
Merged
Conversation
joelamouche
requested changes
Nov 5, 2025
Contributor
There was a problem hiding this comment.
it looks like you could use "vm.readFile(path)" to load the csv directly into foundry, which is cleaner than loading the whole file in env.
That being said, it looks like it would be cleaner and simpler to load from a json.
Example:
{
"recipients": [
{ "address": "0x1111111111111111111111111111111111111111", "amount": "1000000000000000000" },
{ "address": "0x2222222222222222222222222222222222222222", "amount": "2500000000000000000" }
]
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import {TheGuildActivityToken} from "../src/TheGuildActivityToken.sol";
contract BatchMintJson is Script {
using stdJson for string;
// Set your token address (must be owned by PRIVATE_KEY)
address public constant TOKEN = 0x0000000000000000000000000000000000000000;
// Path relative to repo root
string public constant JSON_PATH = "data/recipients.json";
struct Recipient {
address addr;
uint256 amount;
}
function run() external {
uint256 pk = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(pk);
TheGuildActivityToken token = TheGuildActivityToken(TOKEN);
// Read JSON file
string memory json = vm.readFile(JSON_PATH);
// Read array length first
uint256 len = json.readUint(".recipients.length");
for (uint256 i = 0; i < len; i++) {
// Build JSON pointer per index
string memory base = string.concat(".recipients[", vm.toString(i), "]");
address to = json.readAddress(string.concat(base, ".address"));
uint256 amt = json.readUint(string.concat(base, ".amount"));
if (to != address(0) && amt > 0) {
token.mint(to, amt);
}
}
vm.stopBroadcast();
}
}
I think it makes more sense to write the forge script for a json and add a shell utils to convert a csv into a json.
joelamouche
requested changes
Nov 28, 2025
Contributor
joelamouche
left a comment
There was a problem hiding this comment.
Overall great job!
Some fixes needed before we merge this though
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features
Closes #130