博文

目前显示的是 九月, 2025的博文

Baseed Developers 主网合约代码

Based Developers 需要完成5次base主网上面的合约部署,部署Token合约。才能完成角色 标准合代码 Token.sol 复制代码 // 0.5.1-c8a2 // Enable optimization pragma solidity ^0.5.0; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender`...

Base Learn Supreme-5——SCD ERC721 、Minimal Token、ERC20

感谢X用户@isnotberlin提供的代码 以下是,Base Learn Supreme的3个NFT代码,SCD ERC721 、Minimal Token、ERC20 1. Own a(n) SCD ERC721 Pin NFT Solidity 接口 复制代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Importing OpenZeppelin ERC721 contract import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol"; // Interface for interacting with a submission contract interface ISubmission { // Struct representing a haiku struct Haiku { address author; // Address of the haiku author string line1; // First line of the haiku string line2; // Second line of the haiku string line3; // Third line of the haiku } // Function to mint a new haiku function mintHaiku( string memory _line1, string memory _line2, string memory _line3 ) external; // Function to get the total number of haikus function counter() ...

Base Learn Prefect-4——Own a(n) Imports Pin NFT

感谢X用户@isnotberlin提供的代码 以下是,Base Learn Prefect-代码 Own a(n) Imports Pin NFT 1. Own a(n) Imports Pin NFT由两段代码组成SillyStringUtils.sol和imports.sol SillyStringUtils.sol SillyStringUtils.sol 复制代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; library SillyStringUtils { struct Haiku { string line1; string line2; string line3; } function shruggie(string memory _input) internal pure returns (string memory) { return string.concat(_input, unicode" 🤷"); } } 这段代码被imports.sol引用 imports.sol imports.sol 复制代码 // SPDX-License-Identifier: MIT // Importing the SillyStringUtils library import "./SillyStringUtils.sol"; pragma solidity 0.8.17; contract ImportsExercise { // Using the SillyStringUtils library for string manipulation using SillyStringUtils for string; // Declaring a...

Base Learn Prefect-4——Own a(n) Error Triage Pin NFT

复制代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract ErrorTriageExercise { /** * @dev Finds the difference between each uint with its neighbor (a to b, b to c, etc.) * and returns a uint array with the absolute integer difference of each pairing. * * @param _a The first unsigned integer. * @param _b The second unsigned integer. * @param _c The third unsigned integer. * @param _d The fourth unsigned integer. * * @return results An array containing the absolute differences between each pair of integers. */ function diffWithNeighbor( uint _a, uint _b, uint _c, uint _d ) public pure returns (uint[] memory) { // Initialize an array to store the differences uint[] memory results = new uint[](3); // Calculate the absolute difference between each pair of integers and store it in the results array results[0] = _a > _b ? _a - _b : _b - _a; ...

Base Learn Prefect-4-——Own a(n) New Keyword Pin NFT

感谢X用户@isnotberlin提供的代码 以下是,Base Learn Prefect-代码 Own a(n) New Keyword Pin NFT 1. Own a(n) Error Triage Pin NFT由两段代码组成AddressBook.sol和other contract.sol AddressBook.sol AddressBook.sol 复制代码 // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.8; import "@openzeppelin/contracts/access/Ownable.sol"; contract AddressBook is Ownable { // Define a private salt value for internal use string private salt = "value"; // Define a struct to represent a contact struct Contact { uint id; // Unique identifier for the contact string firstName; // First name of the contact string lastName; // Last name of the contact uint[] phoneNumbers; // Array to store multiple phone numbers for the contact } // Array to store all contacts Contact[] private contacts; // Mapping to store the index of each contact in the contacts array using its ID mapping...

Base Learn Consul-3 含代码Mappings、Inheritance、Structs

感谢X用户@timurwp1提供的代码 以下是,Base Learn Consul的3个NFT代码,Mappings 、Inheritance、Structs 1. Own a(n) Mappings Pin NFT ——Contract要选择Submission Solidity 接口 复制代码 // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.23; interface ISubmission { function getApprovedRecords() external view returns (string[] memory); function addRecord(string memory _albumName) external; function getUserFavorites( address _address ) external view returns (string[] memory); function resetUserFavorites() external; } contract Submission is ISubmission { mapping(address => string[]) public userFavorites; function getApprovedRecords() external pure override returns (string[] memory) { string[] memory approved = new string[](9); approved[0] = "Thriller"; approved[1] = "Back in Black"; approved[2] = "The Bodyguard"; ...

Base Learn Acolyte -2含代码Storage、Structures、Arrays

感谢X用户@timurwp1提供的代码 以下是,Base Learn Acolyte的3个NFT代码,Storage、Structures、Arrays 1. Own a(n) Storage Pin NFT Solidity 接口 复制代码 // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.23; contract EmployeeStorage { string public name; uint public idNumber; uint24 private salary; uint16 private shares; constructor() { name = "Pat"; idNumber = 112358132134; salary = 50000; shares = 1000; } function grantShares(uint16 _newShares) external { require(_newShares 直接复制代码,在Remix IDE部署 2. Own a(n) Control Structures Pin NFT Solidity 接口 复制代码 // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.23; contract ControlStructures { error AfterHours(uint256 time); function fizzBuzz(uint256 _number) external pure returns (string memory) { if (_number % 15 == 0) { ...

Base Learn Newcomer - 1 含代码Basic Contracts

Basic Contracts——SafeMathContract 部署的时候要点CONTRACT,然后选择SafeMathContract这个部署,否则会出错 复制代码 // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.23; interface IBasicContractTest { function adder( uint _a, uint _b ) external returns (uint result, bool success); function subtractor( uint _a, uint _b ) external returns (uint result, bool success); } contract SafeMathContract is IBasicContractTest { function adder( uint _a, uint _b ) external pure override returns (uint result, bool success) { if (type(uint).max - _a _a) { return (0, true); } else { result = _a - _b; return (result, false); } } }