Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

How to test smart contract on Sepolia testnet?

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…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




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 thorough unit testing using Hardhat and Chai, but we are going to check if this smart contract is working well on Sepolia testnet.



This article will walk you through deploying the SPX ERC20 token presale smart contract 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:




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.




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.




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.




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






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




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.




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.




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:




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 Sepolia Etherscan.




  • SPX token contract verification




npx hardhat verify 0xF4072Ee965121c2857EeBa0D3e3C6B9795403072 --network sepolia






The command structure is npx hardhat verify <contract_address> <contract constructor arguments> --network <network_name>



The output should be similar to the following:




The contract 0xF4072Ee965121c2857EeBa0D3e3C6B9795403072 has been successfully verified on the block explorer. 
https://sepolia.etherscan.io/address/0xF4072Ee965121c2857EeBa0D3e3C6B9795403072#code

The contract 0xF4072Ee965121c2857EeBa0D3e3C6B9795403072 has already been verified on Sourcify.
https://repo.sourcify.dev/contracts/full_match/11155111/0xF4072Ee965121c2857EeBa0D3e3C6B9795403072/







  • Presale smart contract verification




npx hardhat verify 0x2Ae586f1EbE743eFDCD371E939757EEb42dC6CA7 300000000000 1020000000000 1731542400 2592000 0xF4072Ee965121c2857EeBa0D3e3C6B9795403072 10 --network sepolia






Here, we need to pass the constructor arguments of the Presale smart contract one by one with space .



The output should be similar to the following:




The contract 0x2Ae586f1EbE743eFDCD371E939757EEb42dC6CA7 has been successfully verified on the block explorer.
https://sepolia.etherscan.io/address/0x2Ae586f1EbE743eFDCD371E939757EEb42dC6CA7#code

Successfully verified contract Presale on Sourcify.
https://repo.sourcify.dev/contracts/full_match/11155111/0x2Ae586f1EbE743eFDCD371E939757EEb42dC6CA7/









Testing the Presale smart contract on Sepolia testnet



You can test the Presale smart contract on Sepolia testnet with Sepolia Etherscan.




  • Go to the Sepolia Etherscan 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.



Read functions of Presale smart contract




  • Click on the "Write Contract" tab.



You can see all the write functions of the SPX ERC20 token contract and Presale smart contract.



Write functions of 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.

Ä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 ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94097 | A vulnerability was determined in Netcore NBR200V2 1.3.241127.071246. Th…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick