0.0.4 • Published 1 year ago
@token-kit/tapp-snap v0.0.4
@token-kit/tapp-snap
This is a MetaMask Snap for tapp token.
Features
This project uses @metamask/snaps-sdk to develop the Snap. The features are:
- Display Token metadata, including images, attributes, and descriptions
- Provide Token-related interactive operations
- Support for multiple chains and contracts
- Build user interface using React JSX syntax
Project Structure
src/: Source code directorycomponents/: React componentsActions.tsx: Button Action page componentHomePage.tsx: HomePage page componentTokenPage.tsx: Interactive form component
libs/: Libraryconstants.ts: Some consttypes.ts: Some typesutils.ts: Some common functions
TokenPage.tsx: Interactive form componentindex.tsx: Entry file for the Snapindex.test.tsx: Test file
tsconfig.json: TypeScript configuration filepackage.json: Project dependencies and scripts
Usage
- Run
npm run installto install dependencies - Use
npm run buildto build the project - Use
npm run startto start the project, it will run onhttp://localhost:8080 - Use
npm run testto run tests
Request snap in local
You can use ethereum.request to invoke this snap in local:
await window.ethereum.request({
method: 'wallet_invokeSnap',
params: {
snapId: 'local:http://localhost:8080',
request: {
method: 'import',
params: YOUR_PARAMS,
},
},
});The params are:
chain: ID of the blockchain network.contract: Address of the token contract.tokenId: Token ID.
Testing
The project uses @metamask/snaps-jest for testing. The test file is located at src/index.test.tsx.