This SDK provides utilities for interacting with the Aztec Scan API. Specifically for registering contract metadata. Our full API documentation is available here.
✅ - Register contract artifacts
✅ - Verify contract deployments
✅ - Deployer contact information
# Clone the repository
git clone <repository-url>
cd aztec-scan-sdk
# Install dependencies
npm installThe SDK uses environment variables for configuration. You can either:
- Modify the
.envfile directly - Create a
.env.localfile to override the default values - Set environment variables in your system
Available configuration options:
| Variable | Description | Default |
|---|---|---|
| EXPLORER_API_URL | Base URL for the Aztec Scan API | https://api.aztecscan.xyz/v1 |
| API_KEY | API key for authorization | temporary-api-key |
| DEFAULT_CONTRACT_TYPE | Default contract type | Token |
This script registers a contract artifact (Token contract) with the Explorer API:
npm run register-artifact <contractClassId> [version]Parameters:
contractClassId(required): The contract class ID to registerversion(optional): The version number of the contract (defaults to 1)
Example:
npm run register-artifact 0x07cec63fc8993153bfd64b5a9005af4e80414788c5d25763474db5f516f97d06 1This script verifies a deployed contract instance:
npm run verify-deployment <contractInstanceAddress>Parameters:
contractInstanceAddress(required): The address of the deployed contract instance
Example:
npm run verify-deployment 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdefNote: The script uses hardcoded example values for constructor arguments, deployer information, and other verification parameters. You may need to modify these in the script (scripts/verify-deployment.ts) to match your actual contract deployment.
import {
generateVerifyArtifactUrl,
generateVerifyArtifactPayload,
generateVerifyInstanceUrl,
generateVerifyInstancePayload,
callExplorerApi,
initialize,
} from "aztec-scan-sdk";
// Optional: Initialize with custom settings
initialize({
apiUrl: "https://your-api-url.com",
apiKey: "your-api-key",
});
// Register a contract artifact
const registerArtifact = async (contractClassId, version, artifactObj) => {
const url = generateVerifyArtifactUrl(undefined, contractClassId, version);
const payload = generateVerifyArtifactPayload(artifactObj);
await callExplorerApi({
urlStr: url,
method: "POST",
postData: JSON.stringify(payload),
loggingString: "Register Artifact",
});
};
// Verify a contract deployment
const verifyDeployment = async (
contractInstanceAddress,
verifyArgs,
deployerMetadata,
) => {
const url = generateVerifyInstanceUrl(undefined, contractInstanceAddress);
const payload = {
verifiedDeploymentArguments: generateVerifyInstancePayload(verifyArgs),
deployerMetadata,
};
await callExplorerApi({
urlStr: url,
method: "POST",
postData: JSON.stringify(payload),
loggingString: "Verify Deployment",
});
};npm run buildThis will generate the compiled JavaScript files in the dist directory.
This project is licensed under the Apache-2.0 License.