0.2.3 • Published 1 year ago
@publicspace/solana v0.2.3
Solana Developer Toolkit
Light-weight toolkit for Solana development
Installation
Install @publicspace/solana with npm:
npm install @publicspace/solana
Sign In With Solana
Use Server
Import:
import SIWS from "@publicspace/solana"
Prepare user authentication message:
SIWS.prepare({ domain, address });
Generate user token for 30 minutes:
SIWS.token({ domain, address, statement, signature });
Generate user token with custom expiration:
SIWS.token({ domain, address, statement, signature, expiration });
Verify user certificate:
SIWS.certificate({ token });
Response with HTTP Status Code
Import:
import SIWS, { Utils } from "@publicspace/solana"
Usage on certificate:
const cert = SIWS.certificate({ token: token });
return new Response(Utils.response(cert), {
headers: { "Content-Type": "application/json" }
});
Generate Address or Verify Message
Use Client
Import:
import Wallet from "@publicspace/solana"
Generate mnemonic:
Wallet.mnemonic();
Generate keypair:
Wallet.keypair();
Generate keypair from mnemonic:
Wallet.keypairFromMnemonic({ mnemonic });
Generate keypair from mnemonic and passphrase:
Wallet.keypairFromMnemonic({ mnemonic, passphrase });
Sign message:
Wallet.sign({ message, privateKey });
Verify message:
Wallet.verify({ message, signature, publicKey });