@automata-network/safe-authmodule-sdk v1.5.0
Automata 2.0 Attestors SDK
This SDK includes the following modules:
setup.ts
: Provides a method that deploys a SafeWallet, which enablesAuthModule
and creates an attestation of the user's device upon the initial setup of the wallet.challenge.ts
: Deterministically pre-computes the address of a SafeWallet prior to its deployment. This address is included as a challenge data for the initial attestation.
To install the SDK, do the following:
NPM:
npm install --save-dev @automata-network/safe-authmodule-sdk
YARN:
yarn add --dev @automata-network/safe-authmodule-sdk
To use the SDK, you must first import the two essential functions.
import {
computeSafeAddress,
createNewWallet,
AUTH_MODULE_ADDRESS,
ANDROID_SAFETYNET_ATTESTOR_ADDRESS // this varies by the user's device
} from @automata-network/safe-authmodule-sdk;
// Step 1: Define a random nonce to generate a unique Safe wallet address.
// generates a random number from 0 to MAX_NUMBER - 1
const nonce = Math.floor(Math.random()) * MAX_NUMBER;
// This is OPTIONAL, but recommended. This would assign the provided address as the owner of the SafeWallet.
// SafeWallet is a multi-sig wallet, therefore ownership can be assigned to one or more addresses.
const ownerAddress = await signer.getAddress();
// This is OPTIONAL, but recommended. Some arbitrary number of signatures to execute a transaction (not via device attestation with AuthModule)
// as long as it is less than the number of owners.
const threshold = 5;
// Step 2: Computes the challenge
const safeAddress = await computeSafeAddress(nonce, [ownerAddress], threshold);
// Step 3: Sends a request to the Relayer to create a SafeWallet on chain.
// This step is performed after getting a response from creating a WebAuthn credential.
const response = await createNewWallet(
nonce,
{
authDataBytes,
clientDataJSONBytes // utf8 encoded
},
attStmt,
ANDROID_SAFETYNET_ATTESTOR_ADDRESS,
threshold,
[ownerAddress],
provider // OPTIONAL Web3 provider to overwrite default configurations. This is only used for reading on-chain data.
);
All contract deployment addresses can be found in constants.ts
.
1 year ago
1 year ago
1 year ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago