The MetaMask Snap for BLS Wallet
bls-snap-demo.mov
- Action - Smart contract calldata (includes target contract, data and value).
- Operation - Ordered list of actions.
- Bundle - Ordered list of operations.
- Aggreegator - Service which accepts BLS signed transactions and bundles them into one for submission.
-
Install MetaMask Flask in your Chrome browser. If you have MetaMask installed, you need to disable it because MetaMask does not support Snaps and cannot work with MetaMask Flask at the same time. Take a look FAQ
- Clone the repository
mkdir ./bls-snap cd ./bls-snap git clone https://github.com/aquiladev/bls-snap.git .
- Install dependencies
yarn install
- Run snap with UI
Note: If you have issues on the snap installation, take a look Troubleshooting block.
yarn start
- Run tests
yarn test
The snap has APIs which allow dapps communicate with it.
A dapp must request MetaMask, in order to invoke snap API
await ethereum.request({
method: 'wallet_invokeSnap',
params: {
snapId,
request: {
method: {SNAP_API},
params: {SNAP_API_PARAMS},
},
},
})
ping
- Test API, dapp can hit the API and receivepong
in response.bls_getNetworks
- Returns list of supported networks with their configurations.bls_recoverAccounts
- Returns list of accounts from snap state.bls_createAccount
- Creates and returns new account. Snap uses seedprase from MetaMask through its APIsnap_getBip44Entropy
in order to generate accounts. It allows to re-create the same accounts after snap re-installation.bls_addErc20Token
- Adds ERC20 token to snap state.bls_getErc20Tokens
- Returns list of ERC20 tokens from snap state.bls_removeErc20Token
- Removes ERC20 token from snap state.bls_getErc20TokenBalance
- Returns ERC20 token balance from snap state.bls_getActions
- Returns list of actions from snap state.bls_addAction
- Adds new action to snap state.bls_removeAction
- Removes action from snap state.bls_getBundles
- Returns list of bundles from snap state.bls_getBundle
- Returns the bundle from snap state with status check.bls_sendBundle
- Signs and sends new bundle with ordered list of operations to an aggreegator.
API | Required | Optional |
---|---|---|
ping |
||
bls_getNetworks |
||
bls_recoverAccounts |
chainId |
|
bls_createAccount |
chainId |
addressIndex |
bls_addErc20Token |
chainId ,tokenAddress ,tokenName ,tokenSymbol |
tokenDecimals (default: 18) |
bls_getErc20Tokens |
chainId |
|
bls_removeErc20Token |
chainId ,tokenAddress |
|
bls_getErc20TokenBalance |
chainId ,tokenAddress ,userAddress |
|
bls_getActions |
chainId ,senderAddress |
|
bls_addAction |
chainId ,senderAddress ,contractAddress ,encodedFunction |
value (default: 0), functionFragment |
bls_removeAction |
chainId ,id |
|
bls_getBundles |
chainId ,senderAddress |
|
bls_getBundle |
chainId ,bundleHash |
|
bls_sendBundle |
chainId ,senderAddress , actionIds |
mcl-wasm
has strange behaviour during execution in snap sandbox. one line changed in filemcl_c.js
:toif (scriptDirectory.indexOf("blob:") !== 0) {
Note: This fix requires snap re-installation. You need to build the snap, remove it from MetaMask and install it again.if (typeof scriptDirectory === 'string' && scriptDirectory.indexOf("blob:") !== 0) {