diff --git a/demo/react-app/src/config/chainConfig.ts b/demo/react-app/src/config/chainConfig.ts index c80aabfc0..db987e279 100644 --- a/demo/react-app/src/config/chainConfig.ts +++ b/demo/react-app/src/config/chainConfig.ts @@ -26,8 +26,8 @@ export const CHAIN_CONFIG = { blockExplorerUrl: "https://polygonscan.com/", chainId: "0x89", displayName: "Polygon Mainnet", - ticker: "matic", - tickerName: "Matic", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", logo: "https://images.toruswallet.io/matic.svg", chainNamespace: CHAIN_NAMESPACES.EIP155, } as CustomChainConfig, @@ -36,8 +36,8 @@ export const CHAIN_CONFIG = { blockExplorerUrl: "https://amoy.polygonscan.com/", chainId: "0x13882", displayName: "Polygon Amoy Testnet", - ticker: "matic", - tickerName: "Matic", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", logo: "https://images.toruswallet.io/matic.svg", chainNamespace: CHAIN_NAMESPACES.EIP155, } as CustomChainConfig, diff --git a/demo/react-app/src/services/web3auth.tsx b/demo/react-app/src/services/web3auth.tsx index 4e583af7e..4b0d9e3f8 100644 --- a/demo/react-app/src/services/web3auth.tsx +++ b/demo/react-app/src/services/web3auth.tsx @@ -291,8 +291,8 @@ export const Web3AuthProvider: FunctionComponent = ({ children, blockExplorerUrl: "https://polygonscan.com/", chainId: "0x89", displayName: "Polygon Mainnet", - ticker: "matic", - tickerName: "Matic", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", logo: "https://images.toruswallet.io/matic.svg", chainNamespace: CHAIN_NAMESPACES.EIP155, }; diff --git a/demo/vite-react-app/src/config/chainConfig.ts b/demo/vite-react-app/src/config/chainConfig.ts index c80aabfc0..db987e279 100644 --- a/demo/vite-react-app/src/config/chainConfig.ts +++ b/demo/vite-react-app/src/config/chainConfig.ts @@ -26,8 +26,8 @@ export const CHAIN_CONFIG = { blockExplorerUrl: "https://polygonscan.com/", chainId: "0x89", displayName: "Polygon Mainnet", - ticker: "matic", - tickerName: "Matic", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", logo: "https://images.toruswallet.io/matic.svg", chainNamespace: CHAIN_NAMESPACES.EIP155, } as CustomChainConfig, @@ -36,8 +36,8 @@ export const CHAIN_CONFIG = { blockExplorerUrl: "https://amoy.polygonscan.com/", chainId: "0x13882", displayName: "Polygon Amoy Testnet", - ticker: "matic", - tickerName: "Matic", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", logo: "https://images.toruswallet.io/matic.svg", chainNamespace: CHAIN_NAMESPACES.EIP155, } as CustomChainConfig, diff --git a/demo/vite-react-app/src/services/web3auth.tsx b/demo/vite-react-app/src/services/web3auth.tsx index 5483cac1d..4920c28c5 100644 --- a/demo/vite-react-app/src/services/web3auth.tsx +++ b/demo/vite-react-app/src/services/web3auth.tsx @@ -242,8 +242,8 @@ export const Web3AuthProvider: FunctionComponent = ({ children, blockExplorerUrl: "https://polygonscan.com/", chainId: "0x89", displayName: "Polygon Mainnet", - ticker: "matic", - tickerName: "Matic", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", logo: "https://images.toruswallet.io/matic.svg", chainNamespace: CHAIN_NAMESPACES.EIP155, }; diff --git a/demo/vue-app-new/src/config.ts b/demo/vue-app-new/src/config.ts index 1f4a57244..0e1342060 100644 --- a/demo/vue-app-new/src/config.ts +++ b/demo/vue-app-new/src/config.ts @@ -40,13 +40,12 @@ export const chainConfigs: Record = { }, { chainNamespace: CHAIN_NAMESPACES.EIP155, - rpcTarget: "https://rpc-mumbai.maticvigil.com", - blockExplorerUrl: "https://mumbai-explorer.matic.today", - logo: "https://cryptologos.cc/logos/polygon-matic-logo.png", - chainId: "0x13881", - displayName: "Polygon Mumbai Testnet", - ticker: "matic", - tickerName: "matic", + chainId: "0x13882", + rpcTarget: "https://rpc.ankr.com/polygon_amoy", + displayName: "Polygon Amoy Testnet", + blockExplorerUrl: "https://amoy.polygonscan.com/", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", }, ], [CHAIN_NAMESPACES.SOLANA]: [ diff --git a/demo/vue-app/src/chains/matic.vue b/demo/vue-app/src/chains/matic.vue index 080d1e9d8..96fff9e4e 100644 --- a/demo/vue-app/src/chains/matic.vue +++ b/demo/vue-app/src/chains/matic.vue @@ -36,15 +36,17 @@ import config from "../config"; import EthRpc from "../rpc/ethRpc.vue"; // eslint-disable-next-line @typescript-eslint/no-explicit-any -const polygonMumbaiConfig: any = { +const polygonAmoyConfig: any = { chainNamespace: CHAIN_NAMESPACES.EIP155, - rpcTarget: "https://rpc-mumbai.maticvigil.com", - blockExplorerUrl: "https://mumbai-explorer.matic.today", + chainId: "0x13882", // hex of 80002, polygon testnet + rpcTarget: "https://rpc.ankr.com/polygon_amoy", + // Avoid using public rpcTarget in production. + // Use services like Infura, Quicknode etc + displayName: "Polygon Amoy Testnet", + blockExplorerUrl: "https://amoy.polygonscan.com/", logo: "https://cryptologos.cc/logos/polygon-matic-logo.png", - chainId: "0x13881", - displayName: "Polygon Mumbai Testnet", - ticker: "matic", - tickerName: "matic", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", }; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -59,9 +61,9 @@ const ethereumChainConfig: any = { }; const polygonWeb3AuthOptions: Web3AuthOptions = { - chainConfig: polygonMumbaiConfig, + chainConfig: polygonAmoyConfig, clientId: config.clientId.testnet, - privateKeyProvider: new EthereumPrivateKeyProvider({ config: { chainConfig: polygonMumbaiConfig } }), + privateKeyProvider: new EthereumPrivateKeyProvider({ config: { chainConfig: polygonAmoyConfig } }), enableLogging: true, }; diff --git a/packages/base/src/chain/config.ts b/packages/base/src/chain/config.ts index 7399dd877..e3145d997 100644 --- a/packages/base/src/chain/config.ts +++ b/packages/base/src/chain/config.ts @@ -60,8 +60,8 @@ export const getEvmChainConfig = (chainId: number): CustomChainConfig | null => rpcTarget: "https://rpc.ankr.com/polygon", displayName: "Polygon Mainnet", blockExplorerUrl: "https://polygonscan.com", - ticker: "MATIC", - tickerName: "Polygon", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", }; } if (chainId === 80002) { @@ -72,8 +72,8 @@ export const getEvmChainConfig = (chainId: number): CustomChainConfig | null => rpcTarget: "https://rpc.ankr.com/polygon_amoy", displayName: "Polygon Amoy Testnet", blockExplorerUrl: "https://www.oklink.com/amoy", - ticker: "MATIC", - tickerName: "Polygon", + ticker: "POL", + tickerName: "Polygon Ecosystem Token", decimals: 18, }; } @@ -141,6 +141,18 @@ export const getEvmChainConfig = (chainId: number): CustomChainConfig | null => decimals: 18, }; } + if (chainId === 1946) { + return { + chainNamespace: CHAIN_NAMESPACES.EIP155, + chainId: "0x79a", + rpcTarget: "https://rpc.minato.soneium.org", + displayName: "Soneium Minato Testnet", + blockExplorerUrl: "https://explorer-testnet.soneium.org", + ticker: "ETH", + tickerName: "ETH", + logo: "https://cryptologos.cc/logos/soneium-logo.png", + }; + } return null; }; diff --git a/packages/providers/ethereum-mpc-provider/README.md b/packages/providers/ethereum-mpc-provider/README.md index e53b3e17a..3b19e0e80 100644 --- a/packages/providers/ethereum-mpc-provider/README.md +++ b/packages/providers/ethereum-mpc-provider/README.md @@ -33,30 +33,31 @@ npm install --save @web3auth/ethereum-mpc-provider ## 🩹 Example ```ts -import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-mpc-provider"; -import type { SafeEventEmitterProvider } from "@web3auth/base"; -const signEthMessage = async (provider: SafeEventEmitterProvider): Promise => { - const web3 = new Web3(provider as any); - const accounts = await web3.eth.getAccounts(); - // hex message - const message = "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"; - const signature = await web3.eth.sign(message, accounts[0]); - return signature; +import { Web3AuthMPCCoreKit, WEB3AUTH_NETWORK, makeEthereumSigner } from "@web3auth/mpc-core-kit"; +import { EthereumSigningProvider } from '@web3auth/ethereum-mpc-provider'; +import { CHAIN_NAMESPACES } from "@web3auth/base"; + +const chainConfig = { + chainNamespace: CHAIN_NAMESPACES.EIP155, + chainId: "0x1", // Please use 0x1 for Mainnet + rpcTarget: "https://rpc.ankr.com/eth", + displayName: "Ethereum Mainnet", + blockExplorer: "https://etherscan.io/", + ticker: "ETH", + tickerName: "Ethereum", }; -(async () => { - const provider = await EthereumPrivateKeyProvider.getProviderInstance({ - chainConfig: { - rpcTarget: "https://polygon-rpc.com", - chainId: "0x89", // hex chain id - networkName: "matic", - ticker: "matic", - tickerName: "matic", - }, - privKey: "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318", - }); - const signedMessage = await signEthMessage(provider); -})(); +const coreKitInstance = new Web3AuthMPCCoreKit({ + web3AuthClientId: "YOUR_WEB3AUTH_CLIENT_ID", + web3AuthNetwork: WEB3AUTH_NETWORK.MAINNET, + storage: window.localStorage, + manualSync: true, // This is the recommended approach + tssLib: tssLib +}); + +// Setup provider for EVM Chain +const evmProvider = new EthereumSigningProvider({ config: { chainConfig } }); +evmProvider.setupProvider(makeEthereumSigner(coreKitInstance)); ``` Check out the examples for your preferred blockchain and platform on our [examples page](https://web3auth.io/docs/examples). diff --git a/packages/providers/ethereum-provider/README.md b/packages/providers/ethereum-provider/README.md index b4e8a75e5..690a94da5 100644 --- a/packages/providers/ethereum-provider/README.md +++ b/packages/providers/ethereum-provider/README.md @@ -33,30 +33,34 @@ npm install --save @web3auth/ethereum-provider ## 🩹 Example ```ts +import { CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from "@web3auth/base"; import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider"; -import type { SafeEventEmitterProvider } from "@web3auth/base"; -const signEthMessage = async (provider: SafeEventEmitterProvider): Promise => { - const web3 = new Web3(provider as any); - const accounts = await web3.eth.getAccounts(); - // hex message - const message = "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"; - const signature = await web3.eth.sign(message, accounts[0]); - return signature; +import { Web3Auth, Web3AuthOptions } from "@web3auth/modal"; +const clientId = "YOUR_WEB3AUTH_CLIENT_ID"; // get from https://dashboard.web3auth.io + +const chainConfig = { + chainNamespace: CHAIN_NAMESPACES.EIP155, + chainId: "0xaa36a7", + rpcTarget: "https://rpc.ankr.com/eth_sepolia", + // Avoid using public rpcTarget in production. + // Use services like Infura, Quicknode etc + displayName: "Ethereum Sepolia Testnet", + blockExplorerUrl: "https://sepolia.etherscan.io", + ticker: "ETH", + tickerName: "Ethereum", + logo: "https://cryptologos.cc/logos/ethereum-eth-logo.png", }; -(async () => { - const provider = await EthereumPrivateKeyProvider.getProviderInstance({ - chainConfig: { - rpcTarget: "https://polygon-rpc.com", - chainId: "0x89", // hex chain id - networkName: "matic", - ticker: "matic", - tickerName: "matic", - }, - privKey: "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318", - }); - const signedMessage = await signEthMessage(provider); -})(); +const privateKeyProvider = new EthereumPrivateKeyProvider({ + config: { chainConfig }, +}); + +const web3AuthOptions: Web3AuthOptions = { + clientId, + web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, + privateKeyProvider, +} +const web3auth = new Web3Auth(web3AuthOptions); ``` Check out the examples for your preferred blockchain and platform on our [examples page](https://web3auth.io/docs/examples).