🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 6 Min Lesezeit
0

How to test smart contract on Sepolia testnet?

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




Introduction



Testing smart contracts on a testnet before mainnet deployment is crucial for ensuring functionality and security. The Sepolia testnet provides an ideal environment to test the smart contract with real network conditions without risking real assets.



Real-World Simulation: Testing on a testnet mimics the actual blockchain environment, allowing developers to see how their contracts perform with real transactions and network conditions.



Interaction with Other Contracts: Testnets let developers check how their smart contracts work when interacting with other contracts or dApps, helping to catch potential issues that weren't apparent during unit testing.



We have already done the on the Sepolia testnet, an Ethereum test network and thorough testing it on sepolia etherscan.






Deployment on Sepolia testnet






Configure Hardhat settings



First, we need to configure the Hardhat settings to deploy our smart contract on the Sepolia testnet.




  1. Create a new file named hardhat.config.ts in the root directory of your project.

  2. Open the file and add the following code:




CODE
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "dotenv/config";

const infuraKey: string = process.env.INFURA_API_KEY as string;
const privateKey: string = process.env.PRIVATE_KEY ? process.env.PRIVATE_KEY as string: "";
const etherscanKey: string = process.env.ETHERSCAN_KEY ? process.env.ETHERSCAN_KEY as string: "";

const config: HardhatUserConfig = {
solidity: {
version: "0.8.27",
settings: {
optimizer: {
enabled: true,
runs: 100,
},
viaIR: true,
},
},
networks: {
sepolia: {
url: `https://sepolia.infura.io/v3/${infuraKey}`,
accounts: [`0x${privateKey}`],
},
mainnet: {
url: `https://mainnet.infura.io/v3/${infuraKey}`,
accounts: [`0x${privateKey}`],
},
hardhat: {
chainId: 31337,
},
},
etherscan: {
apiKey: {
eth_mainnet: etherscanKey,
eth_sepolia: etherscanKey
},
},
gasReporter: {
enabled: true,
},
sourcify: {
enabled: true,
},
};

export default config;






Second, we need to create a .env file in the root directory of your project.




CODE
INFURA_API_KEY=your_infura_api_key
PRIVATE_KEY=your_wallet_private_key
ETHERSCAN_KEY=your_etherscan_api_key









Writing the deployment script



First we need to deploy SPX ERC20 token smart contract, so let's create a new file named deploy_SPX.ts in the scripts directory of your project.




CODE
import { ethers } from 'hardhat'

async function main() {
const [deployer] = await ethers.getSigners();
const instanceSPX = await ethers.deployContract("SPX");
await instanceSPX.waitForDeployment()
const SPX_Address = await instanceSPX.getAddress();
console.log(`SPX is deployed. ${SPX_Address}`);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error)
process.exitCode = 1
})






Then, deploy the SPX ERC20 token smart contract on the Sepolia testnet.




CODE
npx hardhat run scripts/deploy_SPX.ts --network sepolia






In the output, you will see the deployed SPX contract address.




CODE
SPX is deployed. 0xF4072Ee965121c2857EeBa0D3e3C6B9795403072






Just copy it and paste it into the spxAddress variable in the deploy_Presale.ts script below.



Similarly, create a new file named deploy_Presale.ts in the scripts directory of your project.




CODE
import { ethers } from 'hardhat'

async function main() {
const softcap = ethers.parseUnits("300000", 6);
const hardcap = ethers.parseUnits("1020000", 6);
const presaleStartTimeInMilliSeconds = new Date("2024-11-15T00:00:00Z"); //2024-11-15T00:00:00Z
const presaleStartTime = Math.floor(presaleStartTimeInMilliSeconds.getTime() / 1000);

const presaleDuration = 24 * 3600 * 30; //30 days
const presaleTokenPercent = 10;
const spxAddress = "0xF4072Ee965121c2857EeBa0D3e3C6B9795403072"; //Deployed SPX token contract on Sepolia

const [deployer] = await ethers.getSigners();

const instancePresale = await ethers.deployContract("Presale", [softcap, hardcap, presaleStartTime, presaleDuration, ficcoAddress, presaleTokenPercent]);
await instancePresale.waitForDeployment();
const Presale_Address = await instancePresale.getAddress();
console.log(`Presale is deployed to ${Presale_Address} and presale start time is ${presaleStartTime}`);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error)
process.exitCode = 1
})






Then, deploy the presale smart contract on the Sepolia testnet.




CODE
npx hardhat run scripts/deploy_Presale.ts --network sepolia






In the output, you will see the deployed Presale contract address.

The output should be similar to the following:




CODE
Presale is deployed to 0x2Ae586f1EbE743eFDCD371E939757EEb42dC6CA7 and presale start time is 1731542400









Testing the Presale smart contract on Sepolia testnet






Verification of the SPX token contract and Presale smart contract on Sepolia testnet



In order to test the SPX token contract and Presale smart contract on Sepolia testnet, we need to verify them on website and search for the SPX ERC20 token contract address and Presale smart contract address.

  • Click on the "Contract" tab.

  • Click on the "Read Contract" tab.



  • You can see all the read-only functions of the SPX ERC20 token contract and Presale smart contract.






    • Connect your MetaMask wallet to Sepolia testnet.



    Make sure you have enough Sepolia ETH and USDT, USDC and DAI faucet in your MetaMask wallet.




    • We can test all the functionalities of the SPX ERC20 token contract and Presale smart contract here.



    Before Presale:




    • Transfer tokens to presale contract.

    • Verify token balance

    • Check the buy functions not working before presale starts



    During Presale:




    • Test buying tokens with different payment methods

    • Verify investment amounts

    • Check token allocation



    After Presale:




    • Set claim time

    • Test claim function

    • Verify token distribution

    • Test withdrawal or refund based on softcap achievement

    • Check the buy functions not working after presale ends



    Make sure all the require statements are working properly and functions are working correctly with the correct input and output and within correct timespan.






    Conclusion



    Testing on Sepolia Testnet provides a realistic environment to validate:




    • Contract functionality

    • Security measures

    • Gas optimization

    • User interaction flows

    • Integration with other contracts



    Always verify all functions thoroughly before proceeding to mainnet deployment. The systematic testing approach on Sepolia ensures a smooth and secure launch on the mainnet.

    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    1 Quelle
    Hackers Just Poisoned the Rust Supply Chain | Threat Wire
    1 Quelle
    Hackers Found a Way Into Humanoid Robots | Threat Wire
    1 Quelle
    Bits und so #1021 (Passwort für Laufwerk)
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten How to test smart contract on Sepolia testnet?

    Thematisch verwandte Begriffe: test, smart, contract, Sepolia · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...