Skip to content

Commit

Permalink
Update test network from goerli to sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillweston committed Mar 31, 2024
1 parent 64a38bd commit 0805d54
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ We use viem library to define the Base network in our project.

Refer to the [Base Network](https://github.com/wevm/viem/blob/main/src/chains/definitions/base.ts) for the definition of the Base Mainnet network in viem.

### Blockchain Information for Base Goerli Network
### Blockchain Information for Base Sepolia Network

|Name|Value|
|-|-|
|Network Name|Base Goerli Testnet|
|Network Name|Base Sepolia Testnet|
|Description|The public testnet for Base.|
|RPC Endpoint|https://goerli.base.org|
|RPC Endpoint|https://sepolia.base.org|
|Chain ID|84531|
|Currency Symbol|ETH|
|Block Explorer|https://goerli.basescan.org|
|Block Explorer|https://sepolia.basescan.org|

Refer to the [Base Goerli Network](https://github.com/wevm/viem/blob/main/src/chains/definitions/baseGoerli.ts) for the definition of the Base Mainnet network in viem.
Refer to the [Base Sepolia Network](https://github.com/wevm/viem/blob/main/src/chains/definitions/baseSepolia.ts) for the definition of the Base Mainnet network in viem.

### Supported Blockchain

Expand Down Expand Up @@ -164,7 +164,7 @@ To successfully deploy and run the project locally, you need to create a `contra
- Open the file in a text editor and add the following JSON structure:
```json
{
"_comment": "Configuration settings for blockchain interaction and Turnstile widget. 'projectId' is the unique identifier for the project, 'activeNetwork' specifies the blockchain network (like 'base' for Base Mainnet or 'baseGoerli' for Goerli Testnet), 'contractAddress' is the address of the smart contract, 'webAddress' is the API endpoint for transaction counts, and 'turnstileSiteKey' is the site key for the Cloudflare Turnstile widget.",
"_comment": "Configuration settings for blockchain interaction and Turnstile widget. 'projectId' is the unique identifier for the project, 'activeNetwork' specifies the blockchain network (like 'baseMainnet' for Base Mainnet or 'baseSepolia' for Sepolia Testnet), 'contractAddress' is the address of the smart contract, 'webAddress' is the API endpoint for transaction counts, and 'turnstileSiteKey' is the site key for the Cloudflare Turnstile widget.",
"activeNetwork": "Your_Network_Choice",
"contractAddress": "Your_Contract_Address",
"webAddress": "Your_Web_Address",
Expand Down Expand Up @@ -195,7 +195,7 @@ Here is an example of what your `contract-config.json` might look like for the B
```json
{
"_comment": "Configuration settings for blockchain interaction and Turnstile widget. 'projectId' is the unique identifier for the project, 'activeNetwork' specifies the blockchain network (like 'base' for Base Mainnet or 'baseGoerli' for Goerli Testnet), 'contractAddress' is the address of the smart contract, 'webAddress' is the API endpoint for transaction counts, and 'turnstileSiteKey' is the site key for the Cloudflare Turnstile widget.",
"_comment": "Configuration settings for blockchain interaction and Turnstile widget. 'projectId' is the unique identifier for the project, 'activeNetwork' specifies the blockchain network (like 'baseMainnet' for Base Mainnet or 'baseSepolia' for Sepolia Testnet), 'contractAddress' is the address of the smart contract, 'webAddress' is the API endpoint for transaction counts, and 'turnstileSiteKey' is the site key for the Cloudflare Turnstile widget.",
"projectId": "0x123abc456def789ghi",
"activeNetwork": "base",
"contractAddress": "0x123abc456def789ghi",
Expand Down
2 changes: 1 addition & 1 deletion create-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');

const config = {
"_comment": "Configuration settings for blockchain interaction and Turnstile widget. 'projectId' is the unique identifier for the project, 'activeNetwork' specifies the blockchain network (like 'base' for Base Mainnet or 'baseGoerli' for Goerli Testnet), 'contractAddress' is the address of the smart contract, 'webAddress' is the API endpoint for transaction counts, and 'turnstileSiteKey' is the site key for the Cloudflare Turnstile widget.",
"_comment": "Configuration settings for blockchain interaction and Turnstile widget. 'projectId' is the unique identifier for the project, 'activeNetwork' specifies the blockchain network (like 'baseMainnet' for Base Mainnet or 'baseSepolia' for Sepolia Testnet), 'contractAddress' is the address of the smart contract, 'webAddress' is the API endpoint for transaction counts, and 'turnstileSiteKey' is the site key for the Cloudflare Turnstile widget.",
"projectId": process.env.PROJECT_ID,
"activeNetwork": process.env.ACTIVE_NETWORK,
"contractAddress": process.env.CONTRACT_ADDRESS,
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ <h5 class="modal-title">Subscription</h5>
<div class="col-lg-7 banner-txt">
<h3>Disney Collaborates: Lotso Coins - Leading the PvP Mode!</h3>
<p>$Lotso is the flagship token of the PvP mode. This design philosophy ensures that the token price continues to rise steadily, allowing players to experience the thrill of rapidly increasing asset values.</p>
<a href="#">Buy Now</a>
<a href="https://app.uniswap.org/explore/tokens/base/0xfafDA17EDEEe4413aC99F6D6443429742593e7Ac">Buy Now</a>
</div>
<div class="col-lg-5">
<div class="banner-img">
Expand Down
19 changes: 14 additions & 5 deletions js/claim-airdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ try {
async function initiateTransaction() {
if (typeof window.ethereum !== 'undefined') {
// MetaMask is installed
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.base.org'));
let web3;
if (activeNetwork === 'baseSepolia') {
web3 = new Web3(new Web3.providers.HttpProvider('https://sepolia.base.org'));
} else if (activeNetwork === 'baseMainnet') {
web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.base.org'));
} else {
console.log('Invalid network selection');
displayMessage('Invalid network selection', 'error');
return;
}

// Updated contract ABI
const contractABI = [
Expand All @@ -54,10 +63,10 @@ async function initiateTransaction() {

try {
const chainId = await window.ethereum.request({ method: 'eth_chainId' });
const isGoerli = chainId === '0x14a33' && activeNetwork === 'baseGoerli';
const isBase = chainId === '0x2105' && activeNetwork === 'base';
const isSepolia = chainId === '0x14a34' && activeNetwork === 'baseSepolia';
const isMainnet = chainId === '0x2105' && activeNetwork === 'baseMainnet';

if (isGoerli || isBase) {
if (isSepolia || isMainnet) {
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
const contract = new web3.eth.Contract(contractABI, contractAddress);
const userAccount = accounts[0];
Expand All @@ -82,7 +91,7 @@ async function initiateTransaction() {
});
} else {
console.log('Incorrect network:', chainId);
displayMessage(`Please switch to the ${activeNetwork === 'baseGoerli' ? 'Goerli Test Network' : 'Base Network'} in your MetaMask wallet.`, 'info');
displayMessage(`Please switch to the ${activeNetwork === 'baseSepolia' ? 'Sepolia Test Network' : 'Mainnet Network'} in your MetaMask wallet.`, 'info');
}
} catch (error) {
console.error('Unable to get the current chain ID:', error);
Expand Down
11 changes: 6 additions & 5 deletions js/wallet-connect.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { createWeb3Modal, defaultWagmiConfig } from '@web3modal/wagmi';
import { base } from 'viem/chains';
import { base, baseSepolia } from 'viem/chains';
import { reconnect, watchAccount, disconnect, getAccount } from '@wagmi/core';

// 1. Get a project ID at https://cloud.walletconnect.com
let projectId;
let activeNetwork, projectId;

try {
// Attempt to load the configuration file
const config = require('../contract-config.json');

// Extracting values from the config
activeNetwork = config.activeNetwork;
projectId = config.projectId;

// Validate the required configuration values
if (!projectId) {
throw new Error("Required configuration value (projectId) is missing.");
if (!activeNetwork || !projectId) {
throw new Error("Required configuration value (activeNetwork or projectId) is missing.");
}

// Use the projectId as needed
Expand All @@ -37,7 +38,7 @@ const metadata = {
icons: ['https://avatars.githubusercontent.com/u/37784886']
};

const chains = [base];
const chains = activeNetwork === 'baseMainnet' ? [base] : [baseSepolia];
export const config = defaultWagmiConfig({
chains,
projectId,
Expand Down

0 comments on commit 0805d54

Please sign in to comment.