Skip to content

Instantly share code, notes, and snippets.

@morgangiraud
Last active October 19, 2022 09:13
Show Gist options
  • Save morgangiraud/358adb3d102c611a1544162e3bdab5a2 to your computer and use it in GitHub Desktop.
Save morgangiraud/358adb3d102c611a1544162e3bdab5a2 to your computer and use it in GitHub Desktop.
How to check if an address is from argent without relying on the argentWalletDetector function
// https://docs.argent.xyz/wallet-connect-and-argent#wallet-detection
import { ethers } from "ethers";
const RPCProviderURL = "";
const argentWalletAddr = "";
// https://etherscan.io/address/0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8#code
const argentDetectorAddr = "0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8";
(async () => {
const provider = new ethers.providers.JsonRpcProvider(RPCProviderURL);
const argentWalletABI = ["function implementation() external view returns (address)"];
const argentWallet = new ethers.Contract(argentWalletAddr, argentWalletABI, provider);
const currentImplem = await argentWallet.implementation();
const argentDetectorABI = [
"function getCodes() public view returns (bytes32[] memory)",
"function getImplementations() public view returns (address[] memory)",
];
const argentWalletDetector = new ethers.Contract(argentDetectorAddr, argentDetectorABI, provider);
const allImplem = await argentWalletDetector.getImplementations();
const allCodes = await argentWalletDetector.getCodes();
const walletCode = await provider.getCode(argentWalletAddr);
const walletCodeHash = ethers.utils.keccak256(walletCode);
console.log({ allCodes });
console.log({ walletCodeHash });
console.log("My code in all possible codes: ", allCodes.indexOf(walletCodeHash) != -1);
console.log({ allImplem });
console.log({ currentImplem });
console.log("My implem in all possible implems: ", allImplem.indexOf(currentImplem) != -1);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment