Quickstart
From independent RPC, wallet to the first news.
1. Install Nodejs SDK#
The SDK provides both ESM, CommonJS and type declarations for browser wallets and Node.js. The current version is distributed through the official documentation download package and has not yet been published to the npm registry.
npm install ethers@^6.17.0 https://x404.app/downloads/x404-sdk-0.1.0.tgzNo repository clone is needed. Install the SDK interface package directly. See SDK Distribution.
2. Configure independent RPC and contract#
import {JsonRpcProvider} from 'ethers';
import {SocialClient} from '@x404/sdk';
// Use the project's public configuration in browsers; Node.js can also read environment variables.
const config = {rpcURL: 'https://YOUR_HTTP_RPC', socialAddress: '0xYOUR_SOCIAL', chainId: 56n};
const provider = new JsonRpcProvider(config.rpcURL);
const social = new SocialClient(config.socialAddress, provider);
await social.verify(config.chainId);
const page = await social.posts(0n, 20);
console.log(page.posts, page.nextCursor);Configure your own RPC, contract address and chain ID. Websites need only HTTP RPC and a user wallet, not WSS. The official same-origin API is not a public cross-origin gateway for third parties.
3. Write after user authorization#
import {BrowserProvider} from 'ethers';
import {SocialClient, metadataURI} from '@x404/sdk';
// Obtain eip1193Provider from your wallet connection component.
const wallet = new BrowserProvider(eip1193Provider);
const social = new SocialClient(SOCIAL_ADDRESS, await wallet.getSigner());
await social.verify(EXPECTED_CHAIN_ID);
const tx = await social.setProfile(
metadataURI({name: 'Alice', description: 'My community profile'}),
0n,
'alice_community',
);
await tx.wait();
const post = await social.publishPost('My first post from an independent app');
await post.wait();The SDK does not save private keys and does not automatically connect to wallets. Read-only providers cannot perform writes. Each write is confirmed by the user's wallet; the backend signature only changes the backend wallet's own social status.
4. Access to background and events#
Both SDKs provide complete queries, transactions and events. Use Nodejs SDKorGo SDK to build a shared index, replay logs from the deployment block and atomically save projections and checkpoints. Continuous HTTP synchronization works independently; WSS subscriptions are optional. Websites read your API and can update through polling, SSE or an application WebSocket.
5. Add your own business#
Social functions can be launched separately; membership, rewards, token payment and customized gameplay are implemented by its own contract or backend. For detailed boundaries seeCustom applications.