BLS Wallet Clients
Client libraries for interacting with BLS Wallet components
Network Config
Deployed contract addresses and metadata.
import { NetworkConfig, getConfig } from 'bls-wallet-clients';
const netCfg: NetworkConfig = await getConfig(
'/path/to/network/config',
async (path) => ...
);
Aggregator
Exposes typed functions for interacting with the Aggregator's HTTP API.
import { Aggregator } from 'bls-wallet-clients';
const aggregator = new Aggregator('https://rinkarby.blswallet.org');
await aggregator.add(...);
BlsWalletWrapper
Wraps a BLS wallet, storing the private key and providing .sign(...)
to
produce a Bundle
, that can be used with aggregator.add(...)
.
import { BlsWalletWrapper } from 'bls-wallet-clients';
const wallet = await BlsWalletWrapper.connect(
privateKey,
verificationGatewayAddress,
provider,
);
const bundle = wallet.sign({
nonce: await wallet.Nonce(),
actions: [
{
ethValue: 0,
contractAddress: someToken.address,
encodedFunction: someToken.interface.encodeFunctionData(
"transfer",
["0x...some address...", ethers.BigNumber.from(1).pow(18)],
),
},
],
});
await aggregator.add(bundle);
VerificationGateway
Exposes VerificationGateway
and VerificationGateway__factory
generated by
typechain to enable typed
interactions with the VerificationGateway
.
import { VerificationGateway__factory } from 'bls-wallet-clients';
const verificationGateway = VerificationGateway__factory.connect(
verificationGatewayAddress,
signer,
);
await verificationGateway.processBundle(bundle);
You can get the results of the operations in a bundle using getOperationResults
.
import { getOperationResults, decodeError } from 'bls-wallet-clients';
...
const txn = await verificationGateway.processBundle(bundle);
const txnReceipt = txn.wait();
const opResults = getOperationResults(txnReceipt);
const { error } = opResults[0];
console.log(error?.actionIndex);
console.log(error?.message);
const errorData = '0x5c66760100000000.............000000000000';
const opResultError = decodeError(errorData);
console.log(opResultError.actionIndex);
console.log(opResultError.message);
Signer
Utilities for signing, aggregating and verifying transaction bundles using the
bls signature scheme. Bundles are actioned in
contracts.
Useful in the aggregator
for verification and aggregation, and in the
extension for signing
and aggregation.
import ethers from "ethers";
import { initBlsWalletSigner } from "bls-wallet-clients";
(async () => {
const signer = await initBlsWalletSigner({ chainId: 10 });
const privateKey = "0x...256 bits of private hex data here";
const someToken = new ethers.Contract(
);
const bundle = signer.sign(
{
nonce: ethers.BigNumber.from(0),
ethValue: ethers.BigNumber.from(0),
contractAddress: someToken.address,
encodedFunction: someToken.interface.encodeFunctionData(
"transfer",
["0x...some address...", ethers.BigNumber.from(10).pow(18)],
),
},
privateKey,
);
})();
Local Development
Setup
yarn install
Build
yarn build
Tests
yarn test
Use in Extension or another project
yarn build
yarn link
cd other/project/dir
yarn "link bls-wallet-clients"