From 306d7e5d39a69a359e77a56e1a76f5263b76b143 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Mar 2026 07:55:33 +0000 Subject: [PATCH 1/2] feat(examples): add create-guild-profile example with brainstormed guild ideas Adds a new `examples/create-guild-profile` script that demonstrates how to create a guild profile using the Guild SDK. The example: - Initialises `createGuildClient` and `createSigner.fromEthersWallet` - Provides five ready-to-use guild profile ideas (name + description) so a user can quickly pick one via the `PROFILE_INDEX` env var - Accepts a `PRIVATE_KEY` env var for a real wallet, or falls back to a randomly generated wallet for local testing - Creates the guild with a free-access "Member" role so anyone can join Wallet used as reference: 0x99295ff548fe9760494a005855a46a958b02a33c https://claude.ai/code/session_01CUJ8tVtqjxLpWxCN3fLYQk --- examples/create-guild-profile/index.ts | 108 ++++++++++++++++++++ examples/create-guild-profile/package.json | 18 ++++ examples/create-guild-profile/tsconfig.json | 12 +++ 3 files changed, 138 insertions(+) create mode 100644 examples/create-guild-profile/index.ts create mode 100644 examples/create-guild-profile/package.json create mode 100644 examples/create-guild-profile/tsconfig.json diff --git a/examples/create-guild-profile/index.ts b/examples/create-guild-profile/index.ts new file mode 100644 index 0000000..ca15083 --- /dev/null +++ b/examples/create-guild-profile/index.ts @@ -0,0 +1,108 @@ +/** + * Create Guild Profile Example + * + * This example demonstrates how to create a guild profile using the Guild SDK. + * It shows how to: + * - Initialize the Guild client + * - Create a signer from a wallet + * - Create a guild with a name, description, and a free-to-join role + * + * Usage: + * PRIVATE_KEY= npm start + * + * The wallet address 0x99295ff548fe9760494a005855a46a958b02a33c is used as an + * example — replace the PRIVATE_KEY env var with your own key when running. + */ + +import { createGuildClient, createSigner } from "@guildxyz/sdk"; +import { Wallet } from "ethers"; + +// --------------------------------------------------------------------------- +// Configuration +// --------------------------------------------------------------------------- + +const GUILD_PROFILES = [ + { + name: "Web3 Builders", + urlName: "web3-builders", + description: + "A community for developers building on-chain applications, protocols, and tooling.", + }, + { + name: "DeFi Explorers", + urlName: "defi-explorers", + description: + "Discover and discuss the latest in decentralised finance — AMMs, lending protocols, and yield strategies.", + }, + { + name: "NFT Creators Collective", + urlName: "nft-creators-collective", + description: + "Artists and collectors shaping the future of digital ownership through NFTs.", + }, + { + name: "DAO Governance Forum", + urlName: "dao-governance-forum", + description: + "A space for DAO contributors to collaborate on proposals, voting, and on-chain governance.", + }, + { + name: "Crypto Security Guild", + urlName: "crypto-security-guild", + description: + "White-hats, auditors, and researchers dedicated to making web3 safer for everyone.", + }, +]; + +// --------------------------------------------------------------------------- +// Main +// --------------------------------------------------------------------------- + +async function main() { + // Resolve the private key from the environment, or fall back to a random + // wallet for demonstration purposes. + const privateKey = process.env.PRIVATE_KEY; + const wallet = privateKey ? new Wallet(privateKey) : Wallet.createRandom(); + + console.log(`Using wallet: ${wallet.address}`); + + const client = createGuildClient("create-guild-profile-example"); + const signer = createSigner.fromEthersWallet(wallet, { + msg: "Create my Guild profile", + }); + + // Pick one of the brainstormed guild ideas (index can be overridden via env) + const profileIndex = Number(process.env.PROFILE_INDEX ?? 0); + const profile = GUILD_PROFILES[profileIndex % GUILD_PROFILES.length]; + + console.log(`\nCreating guild: "${profile.name}"`); + console.log(`Description : ${profile.description}\n`); + + const created = await client.guild.create( + { + name: profile.name, + urlName: profile.urlName, + description: profile.description, + contacts: [], + // Every guild needs at least one role. We add a free-access role so + // anyone can join and explore the community. + roles: [ + { + name: "Member", + requirements: [{ type: "FREE" }], + }, + ], + }, + signer + ); + + console.log("Guild created successfully!"); + console.log(` id : ${created.id}`); + console.log(` urlName : ${created.urlName}`); + console.log(` url : https://guild.xyz/${created.urlName}`); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/create-guild-profile/package.json b/examples/create-guild-profile/package.json new file mode 100644 index 0000000..ae80268 --- /dev/null +++ b/examples/create-guild-profile/package.json @@ -0,0 +1,18 @@ +{ + "name": "create-guild-profile", + "version": "0.1.0", + "private": true, + "type": "module", + "scripts": { + "start": "npx ts-node --esm index.ts" + }, + "dependencies": { + "@guildxyz/sdk": "^2.6.8", + "ethers": "^6.7.1" + }, + "devDependencies": { + "@types/node": "latest", + "ts-node": "^10.9.1", + "typescript": "^5.2.2" + } +} diff --git a/examples/create-guild-profile/tsconfig.json b/examples/create-guild-profile/tsconfig.json new file mode 100644 index 0000000..076ef81 --- /dev/null +++ b/examples/create-guild-profile/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "node", + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true, + "outDir": "dist" + }, + "include": ["index.ts"] +} From 50ab6b9a94a40d0789582a15d86491bb2bd64053 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Mar 2026 00:16:52 +0000 Subject: [PATCH 2/2] Add BeatinDaBlock podcast guild creation example Sets up the create-guild-profile example with BeatinDaBlock branding, including a free-to-join Listener role so fans can join immediately. https://claude.ai/code/session_01CUJ8tVtqjxLpWxCN3fLYQk --- examples/create-guild-profile/index.ts | 70 ++++---------------------- 1 file changed, 11 insertions(+), 59 deletions(-) diff --git a/examples/create-guild-profile/index.ts b/examples/create-guild-profile/index.ts index ca15083..ca2843c 100644 --- a/examples/create-guild-profile/index.ts +++ b/examples/create-guild-profile/index.ts @@ -1,59 +1,16 @@ /** - * Create Guild Profile Example + * Create Guild Profile — BeatinDaBlock Podcast * - * This example demonstrates how to create a guild profile using the Guild SDK. - * It shows how to: - * - Initialize the Guild client - * - Create a signer from a wallet - * - Create a guild with a name, description, and a free-to-join role + * This example demonstrates how to create a guild profile for the + * "BeatinDaBlock" podcast using the Guild SDK. * * Usage: * PRIVATE_KEY= npm start - * - * The wallet address 0x99295ff548fe9760494a005855a46a958b02a33c is used as an - * example — replace the PRIVATE_KEY env var with your own key when running. */ import { createGuildClient, createSigner } from "@guildxyz/sdk"; import { Wallet } from "ethers"; -// --------------------------------------------------------------------------- -// Configuration -// --------------------------------------------------------------------------- - -const GUILD_PROFILES = [ - { - name: "Web3 Builders", - urlName: "web3-builders", - description: - "A community for developers building on-chain applications, protocols, and tooling.", - }, - { - name: "DeFi Explorers", - urlName: "defi-explorers", - description: - "Discover and discuss the latest in decentralised finance — AMMs, lending protocols, and yield strategies.", - }, - { - name: "NFT Creators Collective", - urlName: "nft-creators-collective", - description: - "Artists and collectors shaping the future of digital ownership through NFTs.", - }, - { - name: "DAO Governance Forum", - urlName: "dao-governance-forum", - description: - "A space for DAO contributors to collaborate on proposals, voting, and on-chain governance.", - }, - { - name: "Crypto Security Guild", - urlName: "crypto-security-guild", - description: - "White-hats, auditors, and researchers dedicated to making web3 safer for everyone.", - }, -]; - // --------------------------------------------------------------------------- // Main // --------------------------------------------------------------------------- @@ -66,29 +23,24 @@ async function main() { console.log(`Using wallet: ${wallet.address}`); - const client = createGuildClient("create-guild-profile-example"); + const client = createGuildClient("beatindablock-guild-setup"); const signer = createSigner.fromEthersWallet(wallet, { msg: "Create my Guild profile", }); - // Pick one of the brainstormed guild ideas (index can be overridden via env) - const profileIndex = Number(process.env.PROFILE_INDEX ?? 0); - const profile = GUILD_PROFILES[profileIndex % GUILD_PROFILES.length]; - - console.log(`\nCreating guild: "${profile.name}"`); - console.log(`Description : ${profile.description}\n`); + console.log('\nCreating guild: "BeatinDaBlock"'); const created = await client.guild.create( { - name: profile.name, - urlName: profile.urlName, - description: profile.description, + name: "BeatinDaBlock", + urlName: "beatindablock", + description: + "The official community for BeatinDaBlock — a podcast covering hip-hop culture, music production, and the intersection of beats and blockchain.", contacts: [], - // Every guild needs at least one role. We add a free-access role so - // anyone can join and explore the community. + // Free-to-join listener role so any fan can get access right away. roles: [ { - name: "Member", + name: "Listener", requirements: [{ type: "FREE" }], }, ],