Skip to content

Instantly share code, notes, and snippets.

View floatbeta's full-sized avatar

The Verse floatbeta

View GitHub Profile
@floatbeta
floatbeta / subscription-31-days.lua
Created February 16, 2023 20:07
Here's an example smart contract in Lua that burns an NFT after 1 month from the minted date.
function burnNFT(nftID)
local mintTime = getNFTMintTime(nftID)
local currentTime = os.time()
local secondsInDay = 60 * 60 * 24
local secondsToBurn = secondsInDay * 31
if (currentTime - mintTime >= secondsToBurn) then
burnNFTByID(nftID)
return "NFT " .. nftID .. " burned"
else
@floatbeta
floatbeta / subscription-365-days.lua
Created February 16, 2023 20:05
Here's an example smart contract in Lua that burns an NFT after 12 months from the minted date.
-- Smart contract to burn an NFT after 12 months from the minted date
function constructor()
state.var {
nft = state.nft('nft'),
owner = state.address('owner'),
minted_date = state.value(),
burn_date = state.value()
}
end
@floatbeta
floatbeta / deploy_ft.lua
Created February 4, 2023 03:03
Deploy fungible token on MoltenChain
-- Contract for creating a fungible token on MoltenChain
contract = function()
-- Token details
local name = "My Token"
local symbol = "MTK"
local website = "www.mytoken.com"
local image_url = "https://www.mytoken.com/logo.png"
local description = "This is my token for testing purposes."
local total_supply = 100000000
@floatbeta
floatbeta / deploy_lp.lua
Created February 4, 2023 03:01
Deploy a liquidity pool on MoltenChain.
local molten_chain = require("molten_chain")
local magma_token = molten_chain.new_token("MAGMA")
local token = molten_chain.new_token("TOKEN")
function deploy_liquidity_pool()
-- Check if MAGMA and TOKEN are valid tokens
if not magma_token:is_valid() or not token:is_valid() then
error("Invalid token")
end
-- Non-fungible token mint smart contract
-- constants
local tokenName = "Non-fungible Token"
local tokenDescription = "Non-fungible Token is a unique digital asset on the blockchain. It can be used for various purposes such as digital collectibles, gaming, and more."
-- state variables
local tokenURI = {}
local tokenOwners = {}
local tokenMetadata = {}
@floatbeta
floatbeta / ft-farming.lua
Created February 4, 2023 01:54
This smart contract allows users to farm a fungible token on MoltenChain during a specific period.
-- Fungible Token Farming Smart Contract for MoltenChain
-- Define the name and symbol of the fungible token
local tokenName = "Your Token"
local tokenSymbol = "YURT"
-- Define the total supply of the fungible token
local totalSupply = 100000000
-- Define the farming rate, in this case, 1 token per block
@floatbeta
floatbeta / side-chain.lua
Created February 4, 2023 01:34
Deploy a side-chain for your token on MoltenChain
-- Define the function to deploy the side-chain
function deploy_side_chain(chain_name, token_ticker)
-- Create the side-chain and set the name and token ticker
local side_chain = Chain:new(chain_name, token_ticker)
-- Add the side-chain to the list of side-chains
side_chains[chain_name] = side_chain
-- Return the side-chain for further use
return side_chain
@floatbeta
floatbeta / swap.lua
Created February 4, 2023 01:32
MCSC for swapping tokens
-- define the contract function
function swapTokens(tokenId1, amount1, tokenId2, amount2)
-- get the tokens from the blockchain
local token1 = blockchain.getToken(tokenId1)
local token2 = blockchain.getToken(tokenId2)
-- check that the caller owns the specified amount of token 1
if token1.amount < amount1 then
error("The caller does not own enough of token 1")
end
@floatbeta
floatbeta / lp-lock.lua
Last active February 4, 2023 03:00
Liquidity Lock Smart Contract for MoltenChain.
-- Define the contract
local contract = {
init = function(self)
-- Initialize variables
self.timeLocked = {}
self.lockedAmounts = {}
end,
-- Method to lock up liquidity
lock = function(self, sender, amount, lockTime)
### Keybase proof
I hereby claim:
* I am floatbeta on github.
* I am magm (https://keybase.io/magm) on keybase.
* I have a public key ASAIE1BQL9FbowHaiII1iBMo8-tUgFjWu_NwxyvXJMyl5go
To claim this, I am signing this object: