Created
July 9, 2025 12:07
-
-
Save yann300/1cc49024dca3bb4545124edbec67da9e to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.30+commit.73712a01.js&optimize=false&runs=200&gist=
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
import { Sdk } from '@circles-sdk/sdk' | |
import { BrowserProviderContractRunner } from "@circles-sdk/adapter-ethers" | |
import { cidV0ToUint8Array } from '@circles-sdk/utils' | |
import { ethers } from 'ethers' | |
import type {CirclesConfig} from "@circles-sdk/sdk"; | |
export const circlesConfig: CirclesConfig = { | |
circlesRpcUrl: 'https://static.94.138.251.148.clients.your-server.de/rpc/', | |
pathfinderUrl: 'https://pathfinder.aboutcircles.com', | |
profileServiceUrl: 'https://static.94.138.251.148.clients.your-server.de/profiles/', | |
v1HubAddress: '0x29b9a7fbb8995b2423a71cc17cf9810798f6c543', | |
v2HubAddress: '0x3D61f0A272eC69d65F5CFF097212079aaFDe8267', | |
nameRegistryAddress: '0x8D1BEBbf5b8DFCef0F7E2039e4106A76Cb66f968', | |
migrationAddress: '0x28141b6743c8569Ad8B20Ac09046Ba26F9Fb1c90', | |
baseGroupMintPolicy: '0x79Cbc9C7077dF161b92a745345A6Ade3fC626A60', | |
standardTreasury: '0x3545955Bc3900bda704261e4991f239BBd99ecE5', | |
coreMembersGroupDeployer: '0x7aD59c08A065738e34f13Ac94542867528a1D328', | |
baseGroupFactory:'0x452C116060cBB484eeDD70F32F08aD4F0685B5D2' | |
}; | |
const run = async () => { | |
// Initialize the SDK | |
const adapter = new BrowserProviderContractRunner(); | |
await adapter.init(); | |
const sdk = new Sdk(adapter, circlesConfig) | |
// Define the group profile (symbol is required) | |
const groupProfile = { | |
name: 'Remix', | |
symbol: 'Remix', | |
description: 'A group for all the Remixers.', | |
imageUrl: '', // optional, can be uploaded via SDK | |
previewImageUrl: '', // optional, used for previews | |
} | |
// Define base group setup options | |
const sender = await (new ethers.BrowserProvider(web3Provider)).getSigner() | |
const circlesGroupOwner = '0xf7f307601497eAD8217543Fc9B350Ae6DA5fB5eF' | |
const groupOwner = circlesGroupOwner | |
const serviceAddress = sender.address // Replace with actual service address | |
const feeCollection = circlesGroupOwner // Replace with actual treasury address | |
const initialConditions = [] | |
// Step 1: Create the group profile (CID will be returned) | |
const profileCID = await sdk.profiles.create(groupProfile) | |
if (!profileCID) throw new Error('Failed to create profile CID') | |
// Step 2: Create the base group using the factory | |
console.log('group owner will be', sender) | |
const tx = await sdk.baseGroupFactory.createBaseGroup( | |
groupOwner, // Usually wallet address of the sender | |
serviceAddress, | |
feeCollection, | |
initialConditions, | |
groupProfile.name, | |
groupProfile.symbol, | |
cidV0ToUint8Array(profileCID), // Convert CID to bytes | |
) | |
// Wait for transaction confirmation | |
const receipt = await tx.wait() | |
// Step 3: Extract the group address from emitted events | |
const groupAddress = ethers.stripZerosLeft(receipt.logs[9].topics[1]) | |
// Step 4: Get the avatar for the created group | |
const baseGroupAvatar = await sdk.getAvatar(groupAddress.toLowerCase()) | |
console.log('Base group created at:', groupAddress) | |
console.log('Group avatar:', baseGroupAvatar) | |
} | |
run().catch(console.error).then(console.log) |
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
import { findPath } from '@circles-sdk/pathfinder' | |
import { Sdk } from '@circles-sdk/sdk'; | |
import { CirclesRpc, CirclesData } from '@circles-sdk/data'; | |
import { BrowserProviderContractRunner } from "@circles-sdk/adapter-ethers" | |
(window as any).ethereum = web3Provider | |
const chainConfig: ChainConfig = { | |
pathfinderUrl: 'https://pathfinder.aboutcircles.com', | |
circlesRpcUrl: 'https://rpc.aboutcircles.com', | |
v1HubAddress: '0xdbf22d4e8962db3b2f1d9ff55be728a887e47710', | |
v2HubAddress: '0x2066CDA98F98397185483aaB26A89445addD6740', | |
migrationAddress: '0x2A545B54bb456A0189EbC53ed7090BfFc4a6Af94' | |
}; | |
/* | |
{"jsonrpc":"2.0","id":0,"method":"circlesV2_findPath","params":[{"Source":"0xf7f307601497eAD8217543Fc9B350Ae6DA5fB5eF","Sink":"0x3765c1633eA9dDaD819B1b7d9A27B1E117f789a2","TargetFlow":"1000000000000000000"}]} | |
*/ | |
const run = async () => { | |
try { | |
const adapter = new BrowserProviderContractRunner(); | |
await adapter.init(); | |
const sdk = new Sdk (adapter,chainConfig); | |
/*console.log(await sdk.v2Pathfinder.getPath({ | |
to: '0xf7f307601497eAD8217543Fc9B350Ae6DA5fB5eF', | |
from: '0x257103c7E1293B331d70F1281870b3C454B57208', | |
value: '1' | |
}))*/ | |
const res = await new CirclesRpc(chainConfig.circlesRpcUrl).call<any>('circlesV2_findPath', [{ | |
Source: '0xf7f307601497eAD8217543Fc9B350Ae6DA5fB5eF', | |
Sink: '0xB195C65D7dF6fBCBc49CF89B08d43a5745C783Bd', | |
TargetFlow: '1000000000000000000' | |
}]); | |
console.log(res.result) | |
} catch (e) { | |
console.error(e) | |
} | |
} | |
run().catch(console.error).then(console.log) | |
/* | |
from, | |
to, | |
targetFlow: value, | |
useWrappedBalances, | |
fromTokens, | |
toTokens, | |
excludeFromTokens, | |
excludeToTokens | |
*/ |
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
import { ethers } from 'ethers' | |
import { Sdk } from '@circles-sdk/sdk' | |
import { BrowserProviderContractRunner } from "@circles-sdk/adapter-ethers" | |
const run = async () => { | |
// Initialize the SDK | |
const adapter = new BrowserProviderContractRunner(); | |
await adapter.init(); | |
const sdk = new Sdk(adapter) | |
// 0x2dfcbcbbbd5a763e0f66c77e9749b197f4337a2992e04b131c1bff6942783a88 | |
const provider = new ethers.BrowserProvider(web3Provider) | |
const receipt = await provider.getTransactionReceipt('0x2dfcbcbbbd5a763e0f66c77e9749b197f4337a2992e04b131c1bff6942783a88') | |
const groupAddress = ethers.stripZerosLeft(receipt.logs[15].topics[1]) | |
console.log('group address', groupAddress) | |
const baseGroupAvatar = await sdk.getAvatar(groupAddress.toLowerCase()) | |
console.log('group avatar', baseGroupAvatar) | |
} | |
run().then(console.log).catch(console.error) |
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
import { Sdk } from '@circles-sdk/sdk'; | |
import { CirclesRpc, CirclesData } from '@circles-sdk/data'; | |
import { BrowserProviderContractRunner } from "@circles-sdk/adapter-ethers" | |
(window as any).ethereum = web3Provider | |
const chainConfig: ChainConfig = { | |
pathfinderUrl: 'https://pathfinder.aboutcircles.com', | |
circlesRpcUrl: 'https://rpc.aboutcircles.com', | |
v1HubAddress: '0xdbf22d4e8962db3b2f1d9ff55be728a887e47710', | |
v2HubAddress: '0x2066CDA98F98397185483aaB26A89445addD6740', | |
migrationAddress: '0x2A545B54bb456A0189EbC53ed7090BfFc4a6Af94' | |
}; | |
const run = async () => { | |
try { | |
const adapter = new BrowserProviderContractRunner(); | |
await adapter.init(); | |
// profile: '0xf7f307601497eAD8217543Fc9B350Ae6DA5fB5eF' | |
const address = '0xd97e35b2a5e047ed0a37edfd53daad30f28195d8' | |
const sdk = new Sdk (adapter); | |
const circlesRpc = new CirclesRpc("https://rpc.aboutcircles.com/"); | |
const data = new CirclesData(circlesRpc, chainConfig); | |
// const signerAddress = await signer.getAddress() | |
const avatar = await sdk.getAvatar(address) | |
console.log(await avatar.getMintableAmount()) | |
const avatarInfo = await data.getAvatarInfo(address); | |
console.log(avatarInfo) | |
} catch (e) { | |
console.error(e) | |
} | |
} | |
run().catch(console.error).then(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment