mirror of
https://github.com/farcasterxyz/hub-monorepo.git
synced 2026-04-18 03:00:22 -04:00
docs: update examples for making casts and writing data (#834)
This commit is contained in:
@@ -7,16 +7,20 @@ import * as ed from '@noble/ed25519';
|
||||
|
||||
const HUB_URL = process.env['HUB_ADDR'] || ''; // URL of the Hub
|
||||
|
||||
// If the Hub requests authentication, set the following constants
|
||||
// const HUB_USERNAME = process.env['HUB_USERNAME'] || '';
|
||||
// const HUB_PASSWORD = process.env['HUB_PASSWORD'] || '';
|
||||
|
||||
(async () => {
|
||||
/**
|
||||
* This should be set to the private key of a known signer for the user, instead of randomly generating
|
||||
* one, or the Hubs will reject the message. See the make-data tutorial for examples of how to do this.
|
||||
* one, or the Hubs will reject the message. See the write-data tutorial for examples of how to do this.
|
||||
*/
|
||||
const privateKey = ed.utils.randomPrivateKey();
|
||||
const ed25519Signer = new NobleEd25519Signer(privateKey);
|
||||
|
||||
const dataOptions = {
|
||||
fid: 1,
|
||||
fid: 1, // Set to your fid.
|
||||
network: FarcasterNetwork.DEVNET,
|
||||
};
|
||||
|
||||
@@ -151,5 +155,9 @@ const HUB_URL = process.env['HUB_ADDR'] || ''; // URL of the Hub
|
||||
|
||||
castResults.map((castAddResult) => castAddResult.map((castAdd) => client.submitMessage(castAdd)));
|
||||
|
||||
// If your Hub requires authentication, use the following instead:
|
||||
// const authMetadata = getAuthMetadata(HUB_USERNAME, HUB_PASSWORD);
|
||||
// castResults.map((castAddResult) => castAddResult.map((castAdd) => client.submitMessage(castAdd, authMetadata)));
|
||||
|
||||
client.close();
|
||||
})();
|
||||
|
||||
@@ -16,7 +16,11 @@ import { Wallet } from 'ethers';
|
||||
* Populate the following constants with your own values
|
||||
*/
|
||||
|
||||
const HUB_URL = process.env['HUB_ADDR'] || ''; // URL of the Hub
|
||||
const HUB_URL = process.env['HUB_ADDR'] || ''; // URL of the Hub - make sure to include port 2283
|
||||
|
||||
// If the Hub requests authentication, set the following constants
|
||||
// const HUB_USERNAME = process.env['HUB_USERNAME'] || '';
|
||||
// const HUB_PASSWORD = process.env['HUB_PASSWORD'] || '';
|
||||
|
||||
(async () => {
|
||||
/**
|
||||
@@ -59,6 +63,10 @@ const HUB_URL = process.env['HUB_ADDR'] || ''; // URL of the Hub
|
||||
const client = getInsecureHubRpcClient(HUB_URL);
|
||||
// const client = getSSLHubRpcClient(HUB_URL); if you want to use SSL
|
||||
|
||||
// If your Hub requires authentication, use the following instead:
|
||||
// const authMetadata = getAuthMetadata(HUB_USERNAME, HUB_PASSWORD);
|
||||
// const result = await client.submitMessage(signerAdd);
|
||||
|
||||
const result = await client.submitMessage(signerAdd);
|
||||
result.isOk() ? console.log('SignerAdd was published successfully!') : console.log(result.error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user