Demos Network Specifications
  • Introduction
    • What is Demos Network
    • Demos Network Architecture
  • FAQ
  • Cookbook
    • Project setup
      • Run the project (MacOS)
      • Run the project (Windows)
        • WSL 2 Setup on Windows (10 and 11 only)
        • Issue Troubleshooting
      • Run the project (Ubuntu)
  • SDK
    • Getting Started
    • WebSDK
      • Authentication
        • FIDO2 Passkeys
          • Under the Hood: FIDO2 Passkeys
      • NodeCalls
      • Transactions
        • Creating a transaction
        • Signing a transaction
        • Broadcasting a transaction
      • L2PS SDK
        • The l2ps module
        • Interacting with the L2PS
        • L2PS Messaging System
      • Instant Messaging
        • What is the Instant Messaging Protocol?
        • Architecture Overview
        • Encryption
        • Quickstart
        • Message Types
        • API Reference
        • FAQ
    • Cross Chain
      • General layout of the XM SDKs
      • EVM
      • BTC
      • Solana
      • MultiversX (EGLD)
      • NEAR
      • IBC
      • TON
      • XRPL
      • The XMScript
      • Identities
    • Demoswork
    • Cookbook
      • Demoswork
        • Creating work steps
        • Conditional Operation
        • Base Operation
        • Signing and broadcasting
      • Transactions
        • Crosschain Transaction
        • Native Transactions
      • SWAP
        • Crosschain SWAP
    • Web2
      • Quick Start
      • DAHR API Reference
        • Types
      • Making Requests
      • Identities
        • Twitter
        • GitHub
    • API Reference
    • Bridges
      • Rubic Bridge Test
    • Post Quantum Cryptography
  • Backend
    • Internal Mechanisms
      • Network Time Synchronization
      • Cross Context Identities
    • Global Change Registry
      • GCR Structure
      • How is GCR Synced?
    • Consensus Mechanism
      • Unparalleled Scalability
      • Decentralization in PoR-BFT
      • Enhanced Security
      • Comparative Advantage
      • Addressing Potential Criticisms
      • Conclusion
    • Communications Stack
    • L2PS (Subnet) Framework
      • How are L2PS transactions handled?
    • Miscellaneous
      • Browsing the Postgres DB via psql
    • Bridges
      • Rubic Bridge
    • Developers Testbed
      • Setting up the environment
      • Setting up the repository
      • Installing dependencies
      • Node Configuration
      • Running the node
  • Frontend
    • Demos Providers Discovery Mechanism
Powered by GitBook
On this page
  • 1. Connect your wallet
  • 2. Generate the Proof Payload
  • 3. Send an Identity request
  • 4. Getting linked web2 accounts
  • 5. Removing Twitter identity
  1. SDK
  2. Web2
  3. Identities

Twitter

You can associate your Twitter account with your DEMOS address by following these steps:

1. Connect your wallet

import { Demos } from "@kynesyslabs/demosdk/websdk"
import { Identities } from "@kynesyslabs/demosdk/abstraction";

// the DEMOS rpc
const rpc = "https://demosnode.discus.sh"

const demos = new Demos();
await demos.connect(rpc);
await demos.connectWallet(mnemonic);

2. Generate the Proof Payload

To link your Twitter account to your DEMOS address, you need to create a public tweet containing a proof on your twitter account. The proof is a string that contains a message, a signature and your public key.

You can generate a proof as shown below:

const identities = new Identities();

const proofPayload = await identities.createWeb2ProofPayload(demos)
console.log("Tweet this:", proofPayload)

The proof looks like this:

demos:dw2p:ed25519:e9dd684a031e142ce312b695275b226ab8824f2fd3674db52f28be6c3e9fe027f88a8a9509563....

Open Twitter and create a public tweet containing only the proof string.

3. Send an Identity request

After tweeting the proof, copy the tweet url and use it to create an identity transaction as shown below:

const proof = "https://x.com/cwilvxi/status/1905612827840196726"

const validityData = await identities.addTwitterIdentity(demos, proof)
console.log("validity data: ", validityData)

if (validityData.result == 200){
    const res = await demos.broadcast(validityData)
    console.log(res)
}

A successful transaction response should look like this:

{
  "result": 200,
  "response": {
    "message": "Verified twitter proof. Transaction applied."
  },
  "require_reply": false,
  "extra": {
    "confirmationBlock": 9
  }
}

4. Getting linked web2 accounts

After the confirmation block has been forged, you can retrieve all your linked accounts as shown:

const web2Ids = await identities.getWeb2Identities()

The response should look like this:

{
  "result": 200,
  "response": {
    "twitter": [
      {
        "proof": "https://x.com/cwilvxi/status/1905612827840196726",
        "username": "cwilvxi",
        "proofHash": "d1ebcb162c3d5c7d...a6078a90ee56fb21652"
      }
    ]
  },
  "require_reply": false,
  "extra": null
}

5. Removing Twitter identity

You can create a transaction to remove your linked Twitter account as shown:

const payload = {
    context: "twitter",
    username: "cwilvxi"
}

const validityData = await identities.removeWeb2Identity(demos, payload);

if (validityData.result == 200) {
    const res = await demos.broadcast(validityData);
    console.log(res);
}

A successful transaction response should look like this:

{
  "result": 200,
  "response": {
    "message": "Identity removed. Transaction applied."
  },
  "require_reply": false,
  "extra": {
    "confirmationBlock": 25
  }
}

PreviousIdentitiesNextGitHub

Last updated 11 days ago