Lines 1-40javascript
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.MarketplaceClient = void 0;
4exports.createMarketplaceClient = createMarketplaceClient;
5const ethers_1 = require("ethers");
6const abi_1 = require("./abi");
7const DEFAULT_RPC = "http://127.0.0.1:8545";
8const DEFAULT_MARKETPLACE = "0x5FbDB2315678afecb367f032d93F642f64180aa3";
9const DEFAULT_CHAIN_ID = 31337;
10/** Hardhat account #0 — local relay only */
11const DEFAULT_DEPLOYER_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
12/** Hardhat account #1 — local relay only */
13const DEFAULT_BUYER_KEY = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d";
14function normalizeKey(raw, fallback) {
15 const cleaned = (raw || "").trim().replace(/^"|"$/g, "");
16 if (!cleaned || cleaned.length < 64)
18 return cleaned.startsWith("0x") ? cleaned : `0x${cleaned}`;
20class MarketplaceClient {
21 constructor(config = {}) {
22 this.rpcUrl = config.rpcUrl || process.env.RPC_URL || DEFAULT_RPC;
23 this.marketplaceAddress =
24 config.marketplaceAddress ||
25 process.env.MARKETPLACE_ADDRESS ||
27 this.chainId = config.chainId ?? DEFAULT_CHAIN_ID;
28 this.abi = config.abi ?? abi_1.marketplaceAbi;
29 this.deployerPrivateKey = normalizeKey(config.deployerPrivateKey || process.env.DEPLOYER_PRIVATE_KEY, DEFAULT_DEPLOYER_KEY);
30 this.buyerPrivateKey = normalizeKey(config.buyerPrivateKey || process.env.BUYER_PRIVATE_KEY, DEFAULT_BUYER_KEY);
LowAi Review Evidence
The client accepts private-key environment variables for wallet configuration.
dist/client.jsView on unpkg · L20 33 return new ethers_1.JsonRpcProvider(this.rpcUrl);
36 return new ethers_1.Wallet(this.deployerPrivateKey, this.getProvider());
39 return new ethers_1.Wallet(this.buyerPrivateKey, this.getProvider());