Description:
Smart contract deployed on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
/* ─────────────────────────────────────────────────────────────────────────────
Minimal interfaces
────────────────────────────────────────────────────────────────────────────── */
interface IRelicNFT {
function mintReceipt(
address to,
uint256 ethIn,
uint256 jujuBurned,
uint256 poochMint,
string calldata tag
) external returns (uint256 tokenId);
}
/* ─────────────────────────────────────────────────────────────────────────────
Tiny uint->string (gas-lean)
────────────────────────────────────────────────────────────────────────────── */
library Str {
function utoa(uint256 v) internal pure returns (string memory) {
if (v == 0) return "0";
uint256 j = v; uint256 l;
while (j != 0) { l++; j /= 10; }
bytes memory b = new bytes(l);
j = v;
while (j != 0) { b[--l] = bytes1(uint8(48 + (j % 10))); j /= 10; }
return string(b);
}
}
/* ─────────────────────────────────────────────────────────────────────────────
ERC721-lite RelicNFT
- Focused: ownerOf, balanceOf, name/symbol, Transfer events, mintReceipt
- No approvals/transfers (relics = immutable receipts by default; add later if needed)
- Emits MintReceipt for indexing
────────────────────────────────────────────────────────────────────────────── */
contract RelicNFT is IRelicNFT {
using Str for uint256;
// ERC721-lite surface
string public name;
string public symbol;
mapping(uint256 => address) public ownerOf;
mapping(address => uint256) public balanceOf;
uint256 public totalSupply;
// Optional base for off-chain metadata if you want (can be left blank)
string public baseURI;
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event MintReceipt(
uint256 indexed tokenId,
address indexed to,
uint256 ethIn,
uint256 jujuBurned,
uint256 poochMint,
string tag
);
constructor(
string memory _name,
string memory _symbol,
string memory _baseURI
) {
name = _name;
symbol = _symbol;
baseURI = _baseURI;
}
function _mint(address to) internal returns (uint256 tokenId) {
tokenId = ++totalSupply;
ownerOf[tokenId] = to;
unchecked { balanceOf[to] += 1; }
emit Transfer(address(0), to, tokenId);
}
// Mint a Relic (receipt). Designed to be called by splitter/altar/router.
function mintReceipt(
address to,
uint256 ethIn,
uint256 jujuBurned,
uint256 poochMint,
string calldata tag
) external override returns (uint256 tokenId) {
tokenId = _mint(to);
emit MintReceipt(tokenId, to, ethIn, jujuBurned, poochMint, tag);
}
// Convenience admin: mint a specific “Final Ponzi Receipt” now (if you want a one-shot).
// OPTIONAL: restrict with ownable if desired. Left open for your wiring simplicity.
function mintFinalPonziReceipt(
address to,
uint256 ethIn,
uint256 jujuBurned,
uint256 poochMint,
string calldata tag
) external returns (uint256 tokenId) {
tokenId = _mint(to);
emit MintReceipt(tokenId, to, ethIn, jujuBurned, poochMint, tag);
}
// Optional metadata helpers
function tokenURI(uint256 tokenId) external view returns (string memory) {
require(ownerOf[tokenId] != address(0), "RELIC: !exists");
if (bytes(baseURI).length == 0) return "";
return string(abi.encodePacked(baseURI, Str.utoa(tokenId)));
}
}
/* ─────────────────────────────────────────────────────────────────────────────
OfferingSplitterDynamicV22 (stack-safe)
- Refactor: move relic mint into a dedicated internal function that accepts a compact struct.
- Keep parameters minimal in public function to avoid stack blowup.
- This contract ONLY demonstrates the relic-mint path; wire your splits/treasury in step 4.
────────────────────────────────────────────────────────────────────────────── */
contract OfferingSplitterDynamicV22 {
address public immutable relicNft; // IRelicNFT target
// Keep config tiny to avoid stack pressure.
constructor(address _relicNft) {
require(_relicNft != address(0), "V22: relicNft=0");
relicNft = _relicNft;
}
// Compact payload to reduce stack variables in callers.
struct Receipt {
address to;
uint256 ethIn;
uint256 jujuBurned;
uint256 poochMint;
string tag;
}
// PUBLIC entry: supply minimal args; internally we pack them to a struct.
function recordOfferingAndMintRelic(
uint256 ethIn,
uint256 jujuBurned,
uint256 poochMint,
string calldata tag
) external returns (uint256 tokenId) {
Receipt memory r = Receipt({
to: msg.sender,
ethIn: ethIn,
jujuBurned: jujuBurned,
poochMint: poochMint,
tag: tag
});
tokenId = _mintRelic(r);
}
// If your flow already computed values elsewhere, you can pass them here directly.
function recordFor(address to, Receipt calldata rIn) external returns (uint256 tokenId) {
// enforce recipient override to keep predictable behavior
Receipt memory r = Receipt({
to: to,
ethIn: rIn.ethIn,
jujuBurned: rIn.jujuBurned,
poochMint: rIn.poochMint,
tag: rIn.tag
});
tokenId = _mintRelic(r);
}
// Single tiny call site = avoids “stack too deep” where the error flagged at the `tag` arg.
function _mintRelic(Receipt memory r) internal returns (uint256 tokenId) {
tokenId = IRelicNFT(relicNft).mintReceipt(
r.to,
r.ethIn,
r.jujuBurned,
r.poochMint,
r.tag
);
}
}
Submitted on: 2025-10-02 09:19:03
Comments
Log in to comment.
No comments yet.