Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions examples/create-guild-profile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Create Guild Profile — BeatinDaBlock Podcast
*
* This example demonstrates how to create a guild profile for the
* "BeatinDaBlock" podcast using the Guild SDK.
*
* Usage:
* PRIVATE_KEY=<your-private-key> npm start
*/

import { createGuildClient, createSigner } from "@guildxyz/sdk";
import { Wallet } from "ethers";

// ---------------------------------------------------------------------------
// 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("beatindablock-guild-setup");
const signer = createSigner.fromEthersWallet(wallet, {
msg: "Create my Guild profile",
});

console.log('\nCreating guild: "BeatinDaBlock"');

const created = await client.guild.create(
{
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: [],
// Free-to-join listener role so any fan can get access right away.
roles: [
{
name: "Listener",
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);
});
18 changes: 18 additions & 0 deletions examples/create-guild-profile/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
12 changes: 12 additions & 0 deletions examples/create-guild-profile/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"outDir": "dist"
},
"include": ["index.ts"]
}