@msquared/spike-onchain-sdk
v0.0.22
Published
A TypeScript SDK for game-focused web 3 tooling
Downloads
1,093
Readme
Msquared Web3 SDK
A typescript SDK that abstracts the complexity of using web3 tooling for gaming within a browser or server environment
Key features
- User data backed by an on-chain key value store
Usage
Installation
npm i @msquared/spike-onchain-sdkPeer Dependencies
In order to use this SDK, a viem public and optionally wallet client is required
The goal with this SDK is to detach any keys / signers from on-chain interactions!
Example - Reading Data from chain
import { SDK } from "@msquared/spike-onchain-sdk"
// Instantiate the SDK with just a public viem client
const sdk = new SDK({ public: getPublicClient() })
// Fetch the profile
const profile = await sdk.player.data.getProfile(
wallet as Address, // Adjust this if another wallet wrote the data on-chain
wallet as Address,
)Example - Writing Data on-chain
import { SDK } from "@msquared/spike-onchain-sdk"
// Instantiate the SDK
const sdk = new SDK({
public: getPublicClient(),
wallet: getWalletClient(),
})
// Update the profile onchain
const hash = await sdk.player.data.setProfile(profile, account)