IBOX系统开发核心功能和部分核心源码

IBOX系统核心功能如下:
  一、藏品上链
  数字藏品简单上链,一键快速发行;
  二、藏品分销
  有强大推广分销功能,用户变成推销者;
  三、多端合一
H5端 小程序端,一套系统自由生成;
  四、链上赠予
支持藏品赠予功能,完善用户体验;
五、接口开放
可接入原有APP,小程序等。

以下是iobx系统里藏品单位合成的核心源码

from IBOX import IBOX_ART
import json

# https://etherscan.io/tx/0xbede5e44cc631303a22d066cc269f989469742b5bb6d9a74185e146dab9211e4
# https://mainnet.infura.io/v3/8a264f274fd94de48eb290d35db030ab
# contract address is0x0632aDCab8F12edD3b06F99Dc6078FE1FEDD32B0 

from web3 import Web3
my_provider = Web3.HTTPProvider('https://mainnet.infura.io/v3/8a264f274fd94de48eb290d35db030ab')
w3 = Web3(my_provider)

def main():
    
    contract_address = '0x0632aDCab8F12edD3b06F99Dc6078FE1FEDD32B0'
    contract_abi = json.load(open('surge.abi', 'r'))
    # print(contract_abi)

    mycontract = w3.eth.contract(address=contract_address, abi=contract_abi)
    name = mycontract.functions.name().call()
    print(name)

    symbol = mycontract.functions.symbol().call()
    print(symbol)

    tokenURI = mycontract.functions.tokenURI(1802).call()
    print(tokenURI)

    pass

if __name__ == '__main__':
    main()

使用merkle tree

/// @notice Presale minting verifies callers address is in Merkle Root
/// @param _amountOfTokens Amount of tokens to mint
/// @param _merkleProof Hash of the callers address used to verify the location of that address in the Merkle Root
function presaleMint(uint256 _amountOfTokens, bytes32[] calldata _merkleProof)
    external
    payable
    verifyMaxPerUser(msg.sender, _amountOfTokens)
    verifyMaxSupply(_amountOfTokens)
    isEnoughEth(_amountOfTokens)
{
    require(status == SaleStatus.Presale, "Presale not active");

    bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
    require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Not in presale list");

    _mintedAmount[msg.sender] += _amountOfTokens;
    _safeMint(msg.sender, _amountOfTokens);
}

设置merkle root

/// @notice Set Presale Merkle Root
/// @param _merkleRoot Merkle Root hash
function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner {
    merkleRoot = _merkleRoot;
}

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值