instruction stringclasses 16
values | input stringclasses 9
values | output stringclasses 17
values |
|---|---|---|
Write a binary MLM contract with left/right placement, registration, and matching bonus distribution. Include events and basic anti-whale protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract BinaryMLM is Ownable, ReentrancyGuard {
struct User { address parent; address left; address right; uint256 leftCount; uint256 rightC... | |
Write a binary MLM contract with left/right placement, registration, and matching bonus distribution. Include events and basic anti-whale protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract BinaryMLM is Ownable, ReentrancyGuard {
struct User { address parent; address left; address right; uint256 leftCount; uint256 rightC... | |
Write a binary MLM contract with left/right placement, registration, and matching bonus distribution. Include events and basic anti-whale protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract BinaryMLM is Ownable, ReentrancyGuard {
struct User { address parent; address left; address right; uint256 leftCount; uint256 rightC... | |
Write a binary MLM contract with left/right placement, registration, and matching bonus distribution. Include events and basic anti-whale protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract BinaryMLM is Ownable, ReentrancyGuard {
struct User { address parent; address left; address right; uint256 leftCount; uint256 rightC... | |
Write a binary MLM contract with left/right placement, registration, and matching bonus distribution. Include events and basic anti-whale protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract BinaryMLM is Ownable, ReentrancyGuard {
struct User { address parent; address left; address right; uint256 leftCount; uint256 rightC... | |
Write a binary MLM contract with left/right placement, registration, and matching bonus distribution. Include events and basic anti-whale protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract BinaryMLM is Ownable, ReentrancyGuard {
struct User { address parent; address left; address right; uint256 leftCount; uint256 rightC... | |
Write a unilevel (level income) contract which distributes referral rewards for 10 levels with configurable percentages and gas-optimized payout. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Unilevel {
mapping(address => address) public referrer;
mapping(address => uint256) public balance;
uint8[] public levelPercents = [30,10,5,5,5,5,5,5,5,5]; // basis points for example
function register(address _ref) external {
r... | |
Write a unilevel (level income) contract which distributes referral rewards for 10 levels with configurable percentages and gas-optimized payout. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Unilevel {
mapping(address => address) public referrer;
mapping(address => uint256) public balance;
uint8[] public levelPercents = [30,10,5,5,5,5,5,5,5,5]; // basis points for example
function register(address _ref) external {
r... | |
Write a unilevel (level income) contract which distributes referral rewards for 10 levels with configurable percentages and gas-optimized payout. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Unilevel {
mapping(address => address) public referrer;
mapping(address => uint256) public balance;
uint8[] public levelPercents = [30,10,5,5,5,5,5,5,5,5]; // basis points for example
function register(address _ref) external {
r... | |
Write a unilevel (level income) contract which distributes referral rewards for 10 levels with configurable percentages and gas-optimized payout. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Unilevel {
mapping(address => address) public referrer;
mapping(address => uint256) public balance;
uint8[] public levelPercents = [30,10,5,5,5,5,5,5,5,5]; // basis points for example
function register(address _ref) external {
r... | |
Write a unilevel (level income) contract which distributes referral rewards for 10 levels with configurable percentages and gas-optimized payout. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Unilevel {
mapping(address => address) public referrer;
mapping(address => uint256) public balance;
uint8[] public levelPercents = [30,10,5,5,5,5,5,5,5,5]; // basis points for example
function register(address _ref) external {
r... | |
Write a unilevel (level income) contract which distributes referral rewards for 10 levels with configurable percentages and gas-optimized payout. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Unilevel {
mapping(address => address) public referrer;
mapping(address => uint256) public balance;
uint8[] public levelPercents = [30,10,5,5,5,5,5,5,5,5]; // basis points for example
function register(address _ref) external {
r... | |
Create an ROI pool contract with 1% daily return for 120 days, withdrawal function, and a 300% cap per user. Include SafeMath style checks and events. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract DailyROI is ReentrancyGuard {
struct Deposit { uint256 amount; uint256 start; uint256 claimed; }
mapping(address => Deposit) public deposits;
uint256 public dailyRate = 100; // ... | |
Create an ROI pool contract with 1% daily return for 120 days, withdrawal function, and a 300% cap per user. Include SafeMath style checks and events. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract DailyROI is ReentrancyGuard {
struct Deposit { uint256 amount; uint256 start; uint256 claimed; }
mapping(address => Deposit) public deposits;
uint256 public dailyRate = 100; // ... | |
Create an ROI pool contract with 1% daily return for 120 days, withdrawal function, and a 300% cap per user. Include SafeMath style checks and events. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract DailyROI is ReentrancyGuard {
struct Deposit { uint256 amount; uint256 start; uint256 claimed; }
mapping(address => Deposit) public deposits;
uint256 public dailyRate = 100; // ... | |
Create an ROI pool contract with 1% daily return for 120 days, withdrawal function, and a 300% cap per user. Include SafeMath style checks and events. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract DailyROI is ReentrancyGuard {
struct Deposit { uint256 amount; uint256 start; uint256 claimed; }
mapping(address => Deposit) public deposits;
uint256 public dailyRate = 100; // ... | |
Create an ROI pool contract with 1% daily return for 120 days, withdrawal function, and a 300% cap per user. Include SafeMath style checks and events. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract DailyROI is ReentrancyGuard {
struct Deposit { uint256 amount; uint256 start; uint256 claimed; }
mapping(address => Deposit) public deposits;
uint256 public dailyRate = 100; // ... | |
Create an ROI pool contract with 1% daily return for 120 days, withdrawal function, and a 300% cap per user. Include SafeMath style checks and events. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract DailyROI is ReentrancyGuard {
struct Deposit { uint256 amount; uint256 start; uint256 claimed; }
mapping(address => Deposit) public deposits;
uint256 public dailyRate = 100; // ... | |
Implement a global reward pool that accumulates a percentage of every deposit (tax) and distributes equally among active stakers monthly. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract GlobalPool {
uint256 public pool;
mapping(address => uint256) public stakes;
address[] public stakers;
uint256 public taxBP = 100; // 1%
function deposit() external payable {
uint256 tax = (msg.value * taxBP)/10000;
... | |
Implement a global reward pool that accumulates a percentage of every deposit (tax) and distributes equally among active stakers monthly. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract GlobalPool {
uint256 public pool;
mapping(address => uint256) public stakes;
address[] public stakers;
uint256 public taxBP = 100; // 1%
function deposit() external payable {
uint256 tax = (msg.value * taxBP)/10000;
... | |
Implement a global reward pool that accumulates a percentage of every deposit (tax) and distributes equally among active stakers monthly. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract GlobalPool {
uint256 public pool;
mapping(address => uint256) public stakes;
address[] public stakers;
uint256 public taxBP = 100; // 1%
function deposit() external payable {
uint256 tax = (msg.value * taxBP)/10000;
... | |
Implement a global reward pool that accumulates a percentage of every deposit (tax) and distributes equally among active stakers monthly. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract GlobalPool {
uint256 public pool;
mapping(address => uint256) public stakes;
address[] public stakers;
uint256 public taxBP = 100; // 1%
function deposit() external payable {
uint256 tax = (msg.value * taxBP)/10000;
... | |
Implement a global reward pool that accumulates a percentage of every deposit (tax) and distributes equally among active stakers monthly. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract GlobalPool {
uint256 public pool;
mapping(address => uint256) public stakes;
address[] public stakers;
uint256 public taxBP = 100; // 1%
function deposit() external payable {
uint256 tax = (msg.value * taxBP)/10000;
... | |
Implement a global reward pool that accumulates a percentage of every deposit (tax) and distributes equally among active stakers monthly. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract GlobalPool {
uint256 public pool;
mapping(address => uint256) public stakes;
address[] public stakers;
uint256 public taxBP = 100; // 1%
function deposit() external payable {
uint256 tax = (msg.value * taxBP)/10000;
... | |
Write an auto pool (re-entry) contract where users auto-join the next pool after reaching a milestone. Include event hooks and gas limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract AutoPool {
mapping(uint => address[]) public pools;
mapping(address => uint) public positions;
uint public poolSize = 5;
function join(uint poolId) external payable {
pools[poolId].push(msg.sender);
positions[msg.sender]... | |
Write an auto pool (re-entry) contract where users auto-join the next pool after reaching a milestone. Include event hooks and gas limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract AutoPool {
mapping(uint => address[]) public pools;
mapping(address => uint) public positions;
uint public poolSize = 5;
function join(uint poolId) external payable {
pools[poolId].push(msg.sender);
positions[msg.sender]... | |
Write an auto pool (re-entry) contract where users auto-join the next pool after reaching a milestone. Include event hooks and gas limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract AutoPool {
mapping(uint => address[]) public pools;
mapping(address => uint) public positions;
uint public poolSize = 5;
function join(uint poolId) external payable {
pools[poolId].push(msg.sender);
positions[msg.sender]... | |
Write an auto pool (re-entry) contract where users auto-join the next pool after reaching a milestone. Include event hooks and gas limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract AutoPool {
mapping(uint => address[]) public pools;
mapping(address => uint) public positions;
uint public poolSize = 5;
function join(uint poolId) external payable {
pools[poolId].push(msg.sender);
positions[msg.sender]... | |
Write an auto pool (re-entry) contract where users auto-join the next pool after reaching a milestone. Include event hooks and gas limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract AutoPool {
mapping(uint => address[]) public pools;
mapping(address => uint) public positions;
uint public poolSize = 5;
function join(uint poolId) external payable {
pools[poolId].push(msg.sender);
positions[msg.sender]... | |
Write an auto pool (re-entry) contract where users auto-join the next pool after reaching a milestone. Include event hooks and gas limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract AutoPool {
mapping(uint => address[]) public pools;
mapping(address => uint) public positions;
uint public poolSize = 5;
function join(uint poolId) external payable {
pools[poolId].push(msg.sender);
positions[msg.sender]... | |
Design a 3x matrix MLM contract with spillover—when a position is filled, new users spill to next available position automatically. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Matrix3x {
mapping(address => address[]) public children;
mapping(address => address) public parent;
function register(address _ref) external payable {
// find first available slot under _ref and place user
}
}
| |
Design a 3x matrix MLM contract with spillover—when a position is filled, new users spill to next available position automatically. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Matrix3x {
mapping(address => address[]) public children;
mapping(address => address) public parent;
function register(address _ref) external payable {
// find first available slot under _ref and place user
}
}
| |
Design a 3x matrix MLM contract with spillover—when a position is filled, new users spill to next available position automatically. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Matrix3x {
mapping(address => address[]) public children;
mapping(address => address) public parent;
function register(address _ref) external payable {
// find first available slot under _ref and place user
}
}
| |
Design a 3x matrix MLM contract with spillover—when a position is filled, new users spill to next available position automatically. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Matrix3x {
mapping(address => address[]) public children;
mapping(address => address) public parent;
function register(address _ref) external payable {
// find first available slot under _ref and place user
}
}
| |
Design a 3x matrix MLM contract with spillover—when a position is filled, new users spill to next available position automatically. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Matrix3x {
mapping(address => address[]) public children;
mapping(address => address) public parent;
function register(address _ref) external payable {
// find first available slot under _ref and place user
}
}
| |
Design a 3x matrix MLM contract with spillover—when a position is filled, new users spill to next available position automatically. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Matrix3x {
mapping(address => address[]) public children;
mapping(address => address) public parent;
function register(address _ref) external payable {
// find first available slot under _ref and place user
}
}
| |
Build a staking + referral contract: staking gives yield and the referrer receives a percent of generated yield. Include emergency withdraw and pause. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/Pausable.sol";
contract StakeRef is Pausable {
mapping(address => uint256) public stakeAmount;
mapping(address => address) public referrer;
function stake(address ref) external payable whenNotPaused {
... | |
Build a staking + referral contract: staking gives yield and the referrer receives a percent of generated yield. Include emergency withdraw and pause. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/Pausable.sol";
contract StakeRef is Pausable {
mapping(address => uint256) public stakeAmount;
mapping(address => address) public referrer;
function stake(address ref) external payable whenNotPaused {
... | |
Build a staking + referral contract: staking gives yield and the referrer receives a percent of generated yield. Include emergency withdraw and pause. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/Pausable.sol";
contract StakeRef is Pausable {
mapping(address => uint256) public stakeAmount;
mapping(address => address) public referrer;
function stake(address ref) external payable whenNotPaused {
... | |
Build a staking + referral contract: staking gives yield and the referrer receives a percent of generated yield. Include emergency withdraw and pause. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/Pausable.sol";
contract StakeRef is Pausable {
mapping(address => uint256) public stakeAmount;
mapping(address => address) public referrer;
function stake(address ref) external payable whenNotPaused {
... | |
Build a staking + referral contract: staking gives yield and the referrer receives a percent of generated yield. Include emergency withdraw and pause. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/Pausable.sol";
contract StakeRef is Pausable {
mapping(address => uint256) public stakeAmount;
mapping(address => address) public referrer;
function stake(address ref) external payable whenNotPaused {
... | |
Build a staking + referral contract: staking gives yield and the referrer receives a percent of generated yield. Include emergency withdraw and pause. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/Pausable.sol";
contract StakeRef is Pausable {
mapping(address => uint256) public stakeAmount;
mapping(address => address) public referrer;
function stake(address ref) external payable whenNotPaused {
... | |
Add a 300% income cap and automatic reinvestment when cap is reached. Show how to store user totals safely and prevent overflow. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CapReinvest {
mapping(address => uint256) public totalReceived;
mapping(address => uint256) public deposits;
uint256 public capPercent = 300;
function recordPayout(address user, uint256 amount) internal {
totalReceived[user] += ... | |
Add a 300% income cap and automatic reinvestment when cap is reached. Show how to store user totals safely and prevent overflow. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CapReinvest {
mapping(address => uint256) public totalReceived;
mapping(address => uint256) public deposits;
uint256 public capPercent = 300;
function recordPayout(address user, uint256 amount) internal {
totalReceived[user] += ... | |
Add a 300% income cap and automatic reinvestment when cap is reached. Show how to store user totals safely and prevent overflow. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CapReinvest {
mapping(address => uint256) public totalReceived;
mapping(address => uint256) public deposits;
uint256 public capPercent = 300;
function recordPayout(address user, uint256 amount) internal {
totalReceived[user] += ... | |
Add a 300% income cap and automatic reinvestment when cap is reached. Show how to store user totals safely and prevent overflow. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CapReinvest {
mapping(address => uint256) public totalReceived;
mapping(address => uint256) public deposits;
uint256 public capPercent = 300;
function recordPayout(address user, uint256 amount) internal {
totalReceived[user] += ... | |
Add a 300% income cap and automatic reinvestment when cap is reached. Show how to store user totals safely and prevent overflow. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CapReinvest {
mapping(address => uint256) public totalReceived;
mapping(address => uint256) public deposits;
uint256 public capPercent = 300;
function recordPayout(address user, uint256 amount) internal {
totalReceived[user] += ... | |
Add a 300% income cap and automatic reinvestment when cap is reached. Show how to store user totals safely and prevent overflow. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CapReinvest {
mapping(address => uint256) public totalReceived;
mapping(address => uint256) public deposits;
uint256 public capPercent = 300;
function recordPayout(address user, uint256 amount) internal {
totalReceived[user] += ... | |
Create an internal token (ERC20) that mints on deposits and is used for distribution of referral rewards. Include anti-bot mint limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract InternalToken is ERC20 {
mapping(address => uint256) public lastMint;
uint256 public mintLimit = 1000 * 1e18;
constructor() ERC20("Internal","ITK"){}
function mintForDeposit(addr... | |
Create an internal token (ERC20) that mints on deposits and is used for distribution of referral rewards. Include anti-bot mint limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract InternalToken is ERC20 {
mapping(address => uint256) public lastMint;
uint256 public mintLimit = 1000 * 1e18;
constructor() ERC20("Internal","ITK"){}
function mintForDeposit(addr... | |
Create an internal token (ERC20) that mints on deposits and is used for distribution of referral rewards. Include anti-bot mint limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract InternalToken is ERC20 {
mapping(address => uint256) public lastMint;
uint256 public mintLimit = 1000 * 1e18;
constructor() ERC20("Internal","ITK"){}
function mintForDeposit(addr... | |
Create an internal token (ERC20) that mints on deposits and is used for distribution of referral rewards. Include anti-bot mint limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract InternalToken is ERC20 {
mapping(address => uint256) public lastMint;
uint256 public mintLimit = 1000 * 1e18;
constructor() ERC20("Internal","ITK"){}
function mintForDeposit(addr... | |
Create an internal token (ERC20) that mints on deposits and is used for distribution of referral rewards. Include anti-bot mint limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract InternalToken is ERC20 {
mapping(address => uint256) public lastMint;
uint256 public mintLimit = 1000 * 1e18;
constructor() ERC20("Internal","ITK"){}
function mintForDeposit(addr... | |
Create an internal token (ERC20) that mints on deposits and is used for distribution of referral rewards. Include anti-bot mint limits. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract InternalToken is ERC20 {
mapping(address => uint256) public lastMint;
uint256 public mintLimit = 1000 * 1e18;
constructor() ERC20("Internal","ITK"){}
function mintForDeposit(addr... | |
Sketch a bridge integration function: lock tokens on source chain and emit an event for a relayer. Include nonce and replay protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract SimpleBridge {
mapping(uint64 => bool) public processedNonces;
event Locked(address indexed user, address token, uint256 amount, uint64 nonce);
function lock(address token, uint256 amount, uint64 nonce) external {
require(!processed... | |
Sketch a bridge integration function: lock tokens on source chain and emit an event for a relayer. Include nonce and replay protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract SimpleBridge {
mapping(uint64 => bool) public processedNonces;
event Locked(address indexed user, address token, uint256 amount, uint64 nonce);
function lock(address token, uint256 amount, uint64 nonce) external {
require(!processed... | |
Sketch a bridge integration function: lock tokens on source chain and emit an event for a relayer. Include nonce and replay protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract SimpleBridge {
mapping(uint64 => bool) public processedNonces;
event Locked(address indexed user, address token, uint256 amount, uint64 nonce);
function lock(address token, uint256 amount, uint64 nonce) external {
require(!processed... | |
Sketch a bridge integration function: lock tokens on source chain and emit an event for a relayer. Include nonce and replay protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract SimpleBridge {
mapping(uint64 => bool) public processedNonces;
event Locked(address indexed user, address token, uint256 amount, uint64 nonce);
function lock(address token, uint256 amount, uint64 nonce) external {
require(!processed... | |
Sketch a bridge integration function: lock tokens on source chain and emit an event for a relayer. Include nonce and replay protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract SimpleBridge {
mapping(uint64 => bool) public processedNonces;
event Locked(address indexed user, address token, uint256 amount, uint64 nonce);
function lock(address token, uint256 amount, uint64 nonce) external {
require(!processed... | |
Sketch a bridge integration function: lock tokens on source chain and emit an event for a relayer. Include nonce and replay protection. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract SimpleBridge {
mapping(uint64 => bool) public processedNonces;
event Locked(address indexed user, address token, uint256 amount, uint64 nonce);
function lock(address token, uint256 amount, uint64 nonce) external {
require(!processed... | |
Audit the following contract and identify security issues. Suggest fixes and provide a corrected code snippet. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract ReentrancyExample { mapping(address=>uint) public bal; function withdraw(){ (bool ok,)=msg.sender.call{value:bal[msg.sender]}(""); bal[msg.sender]=0;}} | Issues found: Reentrancy due to external call before state update
Suggested Fix:
Use Checks-Effects-Interactions pattern, update state before external call and add nonReentrant modifier. |
Optimize gas usage in the following contract by refactoring loops and storage access. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract ReentrancyExample { mapping(address=>uint) public bal; function withdraw(){ (bool ok,)=msg.sender.call{value:bal[msg.sender]}(""); bal[msg.sender]=0;}} | Cache storage to memory, limit loops, use unchecked increments, and minimize SSTORE operations. |
Audit the following contract and identify security issues. Suggest fixes and provide a corrected code snippet. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract GasLoop { mapping(address=>uint[]) public data; function process(address u){ for(uint i=0;i<data[u].length;i++){ /* heavy work */ }}} | Issues found: Unbounded loop may run out of gas
Suggested Fix:
Cache lengths, use unchecked increments and limit iterations |
Optimize gas usage in the following contract by refactoring loops and storage access. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract GasLoop { mapping(address=>uint[]) public data; function process(address u){ for(uint i=0;i<data[u].length;i++){ /* heavy work */ }}} | Cache storage to memory, limit loops, use unchecked increments, and minimize SSTORE operations. |
Audit the following contract and identify security issues. Suggest fixes and provide a corrected code snippet. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract OverflowExample { uint256 public total; function add(uint256 v){ total += v; }} | Issues found: Unbounded loop may run out of gas
Suggested Fix:
Cache lengths, use unchecked increments and limit iterations |
Optimize gas usage in the following contract by refactoring loops and storage access. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract OverflowExample { uint256 public total; function add(uint256 v){ total += v; }} | Cache storage to memory, limit loops, use unchecked increments, and minimize SSTORE operations. |
Audit the following contract and identify security issues. Suggest fixes and provide a corrected code snippet. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CapExample { mapping(address=>uint) public income; function pay(address u,uint256 v){ income[u]+=v;} } | Issues found: Unbounded loop may run out of gas
Suggested Fix:
Cache lengths, use unchecked increments and limit iterations |
Optimize gas usage in the following contract by refactoring loops and storage access. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CapExample { mapping(address=>uint) public income; function pay(address u,uint256 v){ income[u]+=v;} } | Cache storage to memory, limit loops, use unchecked increments, and minimize SSTORE operations. |
Fix the withdraw reentrancy bug in the contract below. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Buggy { mapping(address=>uint) public bal; function deposit() external payable { bal[msg.sender]+=msg.value; } function withdraw(uint256 amt) external { require(bal[msg.sender]>=amt); (bool ok,)=msg.sender.call{value:amt}(""); require(ok); bal[msg.sender... | Fix: move bal[msg.sender]-=amt before external call, add nonReentrant modifier and emit events. |
Fix the withdraw reentrancy bug in the contract below. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Buggy { mapping(address=>uint) public bal; function deposit() external payable { bal[msg.sender]+=msg.value; } function withdraw(uint256 amt) external { require(bal[msg.sender]>=amt); (bool ok,)=msg.sender.call{value:amt}(""); require(ok); bal[msg.sender... | Fix: move bal[msg.sender]-=amt before external call, add nonReentrant modifier and emit events. |
Add security to this pool contract. | contract SimplePool { function withdraw(uint amt) external { payable(msg.sender).transfer(amt); } } | Add access control, nonReentrant, and checks-effects-interactions; require balances and update before transfer. |
Optimize this gas-heavy loop. | function sum(uint[] memory arr) public pure returns (uint){ uint s=0; for(uint i=0;i<arr.length;i++){ s+=arr[i]; } return s; } | Optimize by caching length, using unchecked increment, and declare return var: function sum(uint[] memory arr) public pure returns (uint total){ uint len = arr.length; for (uint i=0;i<len;){ total += arr[i]; unchecked{ i++; } } } |
Optimize this gas-heavy loop. | function sum(uint[] memory arr) public pure returns (uint){ uint s=0; for(uint i=0;i<arr.length;i++){ s+=arr[i]; } return s; } | Optimize by caching length, using unchecked increment, and declare return var: function sum(uint[] memory arr) public pure returns (uint total){ uint len = arr.length; for (uint i=0;i<len;){ total += arr[i]; unchecked{ i++; } } } |
Optimize this gas-heavy loop. | function sum(uint[] memory arr) public pure returns (uint){ uint s=0; for(uint i=0;i<arr.length;i++){ s+=arr[i]; } return s; } | Optimize by caching length, using unchecked increment, and declare return var: function sum(uint[] memory arr) public pure returns (uint total){ uint len = arr.length; for (uint i=0;i<len;){ total += arr[i]; unchecked{ i++; } } } |
Fix the withdraw reentrancy bug in the contract below. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Buggy { mapping(address=>uint) public bal; function deposit() external payable { bal[msg.sender]+=msg.value; } function withdraw(uint256 amt) external { require(bal[msg.sender]>=amt); (bool ok,)=msg.sender.call{value:amt}(""); require(ok); bal[msg.sender... | Fix: move bal[msg.sender]-=amt before external call, add nonReentrant modifier and emit events. |
Fix the withdraw reentrancy bug in the contract below. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Buggy { mapping(address=>uint) public bal; function deposit() external payable { bal[msg.sender]+=msg.value; } function withdraw(uint256 amt) external { require(bal[msg.sender]>=amt); (bool ok,)=msg.sender.call{value:amt}(""); require(ok); bal[msg.sender... | Fix: move bal[msg.sender]-=amt before external call, add nonReentrant modifier and emit events. |
Refactor the legacy contract to modern best practices. | contract Legacy { mapping(address=>uint) public bal; function deposit() payable external { bal[msg.sender]+=msg.value; } } | Refactor: use OpenZeppelin libraries, add events, use uint256, add input validation and documentation. |
Fix the withdraw reentrancy bug in the contract below. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Buggy { mapping(address=>uint) public bal; function deposit() external payable { bal[msg.sender]+=msg.value; } function withdraw(uint256 amt) external { require(bal[msg.sender]>=amt); (bool ok,)=msg.sender.call{value:amt}(""); require(ok); bal[msg.sender... | Fix: move bal[msg.sender]-=amt before external call, add nonReentrant modifier and emit events. |
Fix the withdraw reentrancy bug in the contract below. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Buggy { mapping(address=>uint) public bal; function deposit() external payable { bal[msg.sender]+=msg.value; } function withdraw(uint256 amt) external { require(bal[msg.sender]>=amt); (bool ok,)=msg.sender.call{value:amt}(""); require(ok); bal[msg.sender... | Fix: move bal[msg.sender]-=amt before external call, add nonReentrant modifier and emit events. |
Fix the withdraw reentrancy bug in the contract below. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Buggy { mapping(address=>uint) public bal; function deposit() external payable { bal[msg.sender]+=msg.value; } function withdraw(uint256 amt) external { require(bal[msg.sender]>=amt); (bool ok,)=msg.sender.call{value:amt}(""); require(ok); bal[msg.sender... | Fix: move bal[msg.sender]-=amt before external call, add nonReentrant modifier and emit events. |
Optimize this gas-heavy loop. | function sum(uint[] memory arr) public pure returns (uint){ uint s=0; for(uint i=0;i<arr.length;i++){ s+=arr[i]; } return s; } | Optimize by caching length, using unchecked increment, and declare return var: function sum(uint[] memory arr) public pure returns (uint total){ uint len = arr.length; for (uint i=0;i<len;){ total += arr[i]; unchecked{ i++; } } } |
Optimize this gas-heavy loop. | function sum(uint[] memory arr) public pure returns (uint){ uint s=0; for(uint i=0;i<arr.length;i++){ s+=arr[i]; } return s; } | Optimize by caching length, using unchecked increment, and declare return var: function sum(uint[] memory arr) public pure returns (uint total){ uint len = arr.length; for (uint i=0;i<len;){ total += arr[i]; unchecked{ i++; } } } |
Fix the withdraw reentrancy bug in the contract below. | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Buggy { mapping(address=>uint) public bal; function deposit() external payable { bal[msg.sender]+=msg.value; } function withdraw(uint256 amt) external { require(bal[msg.sender]>=amt); (bool ok,)=msg.sender.call{value:amt}(""); require(ok); bal[msg.sender... | Fix: move bal[msg.sender]-=amt before external call, add nonReentrant modifier and emit events. |
Optimize this gas-heavy loop. | function sum(uint[] memory arr) public pure returns (uint){ uint s=0; for(uint i=0;i<arr.length;i++){ s+=arr[i]; } return s; } | Optimize by caching length, using unchecked increment, and declare return var: function sum(uint[] memory arr) public pure returns (uint total){ uint len = arr.length; for (uint i=0;i<len;){ total += arr[i]; unchecked{ i++; } } } |
Refactor the legacy contract to modern best practices. | contract Legacy { mapping(address=>uint) public bal; function deposit() payable external { bal[msg.sender]+=msg.value; } } | Refactor: use OpenZeppelin libraries, add events, use uint256, add input validation and documentation. |
Optimize this gas-heavy loop. | function sum(uint[] memory arr) public pure returns (uint){ uint s=0; for(uint i=0;i<arr.length;i++){ s+=arr[i]; } return s; } | Optimize by caching length, using unchecked increment, and declare return var: function sum(uint[] memory arr) public pure returns (uint total){ uint len = arr.length; for (uint i=0;i<len;){ total += arr[i]; unchecked{ i++; } } } |
Refactor the legacy contract to modern best practices. | contract Legacy { mapping(address=>uint) public bal; function deposit() payable external { bal[msg.sender]+=msg.value; } } | Refactor: use OpenZeppelin libraries, add events, use uint256, add input validation and documentation. |
Add security to this pool contract. | contract SimplePool { function withdraw(uint amt) external { payable(msg.sender).transfer(amt); } } | Add access control, nonReentrant, and checks-effects-interactions; require balances and update before transfer. |
README.md exists but content is empty.
- Downloads last month
- 6