SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'{\rtf1\ansi\ansicpg1252\cocoartf2639
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\deftab560
\pard\pardeftab560\slleading20\partightenfactor0
\f0\fs26 \cf0 FUNCTION Initialize()\
10 LET owner = SIGNER()\
20 LET totalSupply = 100000000\
30 LET preMinted = 2000000\
40 LET minedSupply = preMinted\
50 LET name = "Captain"\
60 LET symbol = "Capt"\
70 LET decimals = 2\
80 LET miningReward = 250\
90 LET miningCooldown = 900 ' 900 seconds = 15 minutes\
100 STORE("owner", owner)\
110 STORE("totalSupply", totalSupply)\
120 STORE("minedSupply", minedSupply)\
130 STORE("name", name)\
140 STORE("symbol", symbol)\
150 STORE("decimals", decimals)\
160 STORE("miningReward", miningReward)\
170 STORE("miningCooldown", miningCooldown)\
180 STORE(owner, preMinted) ' Assign 2 million to the owner\
190 RETURN 1\
END FUNCTION\
\
FUNCTION Transfer(to STRING, amount INTEGER)\
10 LET sender = SIGNER()\
20 IF LOAD(sender) < amount THEN RETURN 0\
30 LET senderBalance = LOAD(sender) - amount\
40 LET receiverBalance = LOAD(to) + amount\
50 STORE(sender, senderBalance)\
60 STORE(to, receiverBalance)\
70 RETURN 1\
END FUNCTION\
\
FUNCTION BalanceOf(account STRING) INTEGER\
10 RETURN LOAD(account)\
END FUNCTION\
\
FUNCTION Burn(amount INTEGER)\
10 LET sender = SIGNER()\
20 IF LOAD(sender) < amount THEN RETURN 0\
30 LET senderBalance = LOAD(sender) - amount\
40 LET newTotalSupply = LOAD("totalSupply") - amount\
50 STORE(sender, senderBalance)\
60 STORE("totalSupply", newTotalSupply)\
70 RETURN 1\
END FUNCTION\
\
FUNCTION Mine()\
10 LET miner = SIGNER()\
20 LET reward = LOAD("miningReward")\
30 LET cooldown = LOAD("miningCooldown")\
40 LET lastMineTime = LOAD(miner + "_lastMine")\
\
' Check if the user has mined recently\
50 IF BLOCK_TIMESTAMP < lastMineTime + cooldown THEN RETURN 0\
\
' Check that mining does not exceed total supply\
60 IF LOAD("minedSupply") + reward > LOAD("totalSupply") THEN RETURN 0\
\
' Update balance and increase mined supply\
70 LET minerBalance = LOAD(miner) + reward\
80 LET newMinedSupply = LOAD("minedSupply") + reward\
90 STORE(miner, minerBalance)\
100 STORE("minedSupply", newMinedSupply)\
110 STORE(miner + "_lastMine", BLOCK_TIMESTAMP)\
120 RETURN 1\
END FUNCTION}'] |