iBox系统源码分享,ibox的核心源码

 iBox系统核心源码分享

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;
}

 iBox系统的核心源码开发导图

iBox系统源码分享,ibox的核心源码_第1张图片

iBox数字藏品NFT系统源码开发

在元宇宙中,Ibox数字藏品也是一种数字资产的表现形式,也可以说它是现实资产的数字权益认证。随着元宇宙的建设需求变得越来越强烈,数字藏品作为链接现实世界和元宇宙世界的桥梁,自然也会起到更加重要的作用。

因此,我们可以说,购买Ibox数字藏品,也是提前购买未来数字世界的权益。

Ibox数字藏品并不仅仅是一部分人当作投机、套利的工具,购买数字藏品,其实背后还有不少的附加价值产生,比如一些平台的赋能,一些实体纪念物的投放,以及一些线下见面交流会的参与资格等等。

说白了我们买的就是一个存在于元宇宙的独一五二的Ibox数字化收藏品,这个藏品你可以用来交易,可以用来收藏。而且这个Ibox藏品在公链拥有独一五二的标识,流转记录都是可以被追溯到的,所以,这对版权保护是非常有利的,也非常有利于保护消费者的权益。目前看来,Ibox数字藏品也是一直往健康长期规范化的方向在发展着,这个对于我们数字藏品的收藏者来说,无疑是非常好的方向。

而中国由于未打开二级市场,藏家们的心态更偏向于“藏”,在购入藏品时更注重其艺术价值和文化价值。许多藏家都是传统艺术领域的爱好者,对他们来说,数字藏品跟藏品是一样的,只是在技术的保护下,藏品“保质期”更长了。

尽Ibox管数字藏品进入国内市场相较海外要晚一些,不过国内数字藏品市场正在走出一条中国特色Ibox数字藏品之路。细数各大大平台发行的数字藏品,绝大多数都是文创类数字藏品。数据显示,在鲸探上,来自传统文化相关IP的数字藏品占比达到70%。

从国内Ibox数字藏品的发行领域可以看出,Ibox数字藏品的价值不再聚焦于货币属性,而是开发出了更多商业化的可能,同时也将中国传统文化和优的国产IP进一步推广出去。

新生事物必然伴随着泡沫,在数字藏品热下,出现了一部分炒家搅乱市场,一些场外交易、操盘炒作等事件。不过各平台的相关规范政策也迅速跟上,出台一系列处罚措施来规范市场。随着监管的完善,行业逐渐步入成熟,在各大平台的共同努力下,中国特色数字藏品也正在用技术为民族文化赋能,激发文化产业的新活力。

以下是iobx电商系统藏品交易的部分源码

class Pay extends BaseApi
{
    
    public $ibox_config;

    public function __construct($params = [])
    {
        parent::__construct($params);
        $config = new ConfigService();
        $this->shop_config = $config->getShopConfig(0);
    }
    
    /**
     * 获取支付相关信息
     */
    public function getPayValue()
    {
        $title = "获取支付信息";
        if (empty($this->uid)) {
            return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
        }
        $out_trade_no = $page_index = isset($this->params['out_trade_no']) ? $this->params['out_trade_no'] : 1;;
        if (empty($out_trade_no)) {
            return $this->outMessage($title, "", -50, "缺少必填参数out_trade_no");
        }
        $is_support_pintuan = IS_SUPPORT_PINTUAN;
        
        if ($is_support_pintuan == 1) {
            
            $pintuan = new Pintuan();
            $res = $pintuan->orderPayBefore($out_trade_no);
            if ($res == 0)
                return $this->outMessage($title, "", -50, "拼团支付已关闭!");
            
        }
        $pay = new UnifyPay();
        $member = new MemberService();
        $pay_value = $pay->getPayInfo($out_trade_no);
        
        if ($pay_value['pay_status'] != 0) {
            // 订单已经支付
            return $this->outMessage($title, '', -50, '订单已经支付或者订单价格为0.00,无需再次支付!');
        }
        if ($pay_value['type'] == 1) {
            // 订单
            $order_status = $this->getOrderStatusByOutTradeNo($out_trade_no);
            // 订单关闭状态下是不能继续支付的
            if ($order_status == 5) {
                return $this->outMessage($title, '', -50, '订单已关闭');
            }
        }
        
        $zero1 = time(); // 当前时间 ,注意H 是24小时 h是12小时
        $zero2 = $pay_value['create_time'];
        
        $order_query = new OrderQuery();
        $order_info = $order_query->getOrderInfo([ "out_trade_no" => $out_trade_no ]);
        
        if ($zero1 > ($zero2 + ($this->shop_config['order_buy_close_time'] * 60)) && $order_info['order_type'] != 6 && $this->shop_config['order_buy_close_time'] != 0) {
            return $this->outMessage($title, '', -50, '订单已关闭');
        } else {
            
            $member_info = $member->getUserInfo();
            
            $data = array(
                'pay_value' => $pay_value,
                'nick_name' => $member_info['nick_name']
            );
            return $this->outMessage($title, $data);
        }
        
    }
    
    /**
     * 订单待支付
     */
    public function orderPay()
    {
        $title = '订单待支付';
        $order_id = request()->post('order_id', 0);
        $order_action = new \data\service\OrderAction();
        $order_query = new OrderQuery();
        if ($order_id != 0) {
            // 更新支付流水号
            $order_action->createNewOutTradeNoReturnBalance($order_id);
            $new_out_trade_no = $order_query->getOrderOutTradeNo($order_id);
            if (empty($new_out_trade_no)) {
                return $this->outMessage($title, '', -1, '支付配置有误');
            }
            return $this->outMessage($title, $new_out_trade_no);
        } else {
            return $this->outMessage($title, '', -1, '无法获取支付信息');
        }
    }
    
    /**
     * 预售定金待支付
     */
    public function orderPresellPay()
    {
        $title = '预售定金待支付';
        if (empty($this->uid)) {
            return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
        }
        $order_id = request()->post('order_id', 0);
        
        $oder_presell = new Orderpresell();
        $presell_order_info = $oder_presell->getOrderPresellInfo(0, [
            'relate_id' => $order_id
        ]);
        $presell_order_id = $presell_order_info['presell_order_id'];
        
        if ($presell_order_id != 0) {
            // 更新支付流水号
            $oder_presell->createNewOutTradeNoReturnBalancePresellOrder($presell_order_id);
            $new_out_trade_no = $oder_presell->getPresellOrderOutTradeNo($presell_order_id);
            return $this->outMessage($title, $new_out_trade_no);
        } else {
            return $this->outMessage($title, '', -1, '无法获取支付信息');
        }
    }
    
    /**
     * 根据外部交易号查询订单状态,订单关闭状态下是不能继续支付的
     */
    public function getOrderStatusByOutTradeNo()
    {
        $title = "获取订单状态";
        
        $out_trade_no = isset($this->params['out_trade_no']) ? $this->params['out_trade_no'] : '';
        if (empty($out_trade_no)) {
            return $this->outMessage($title, "", '-50', "缺少必填参数out_trade_no");
        }
        $order_query = new OrderQuery();
        if (empty($this->uid)) {
            return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
        }
        $order_status = $order_query->getOrderStatusByOutTradeNo($out_trade_no);
        
        if (!empty($order_status)) {
            return $this->outMessage($title, [ "order_status" => $order_status['order_status'] ]);
        }
        return $this->outMessage($title, [ "order_status" => 0 ]);
    }
    
    /**
     * 小程序支付
     */
    public function appletWechatPay()
    {
        $title = "订单支付!";
        if (addon_is_exit('NsWeixinpay') != 1) {
            return $this->outMessage($title, "", '-10', "缺少微信支付插件");
        }
        if (empty($this->uid)) {
            return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
        }
        $is_applet = $this->get('is_applet');
        if ($is_applet != 1) {
            return $this->outMessage($title, "", '-50', "错误的支付环境");
        }
        $out_trade_no = request()->post('out_trade_no', '');
        $openid = request()->post('openid', '');
        $is_uniapp = $this->get('is_uniapp', 0);
        if (empty($out_trade_no)) {
            return $this->outMessage($title, "", '-50', "无法识别的交易号");
        }
        $red_url = str_replace("/index.php", "", __URL__);
        $red_url = str_replace("/api.php", "", __URL__);
        $red_url = str_replace("index.php", "", $red_url);
        $red_url = $red_url . "/pay.php";
        $pay = new PayService();
        $config = new WxpayConfig();
        
        if (empty($openid) && $is_uniapp) {
            $third_party = new ThirdParty();
            $openid = $third_party->getOpenid('wxpay', $this->uid);
        }
        
        $res = $pay->wchatPay($out_trade_no, 'APPLET', $red_url, $openid);
        $wchat_config = $config->getWpayConfig($this->instance_id);
        
        if ($res["result_code"] == "SUCCESS" && $res["return_code"] == "SUCCESS") {
            $appid = $res["appid"];
            $nonceStr = $res["nonce_str"];
            $package = $res["prepay_id"];
            $signType = "MD5";
            $key = $wchat_config['value']['mch_key'];
            $timeStamp = time();
            $sign_string = "appId=$appid&nonceStr=$nonceStr&package=prepay_id=$package&signType=$signType&timeStamp=$timeStamp&key=$key";
            $paySign = strtoupper(md5($sign_string));
            $res["timestamp"] = $timeStamp;
            $res["PaySign"] = $paySign;
        }
        return $this->outMessage($title, $res);
    }
    
    /**
     * 根据流水号查询订单编号,
     * 创建时间:2022年2月9日 18:36:54
     *
     * @param string $out_trade_no
     * @return string
     */
    public function getOrderNoByOutTradeNo()
    {
        $title = '查询订单号';
//         if (empty($this->uid)) {
//             return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
//         }
        $out_trade_no = isset($this->params['out_trade_no']) ? $this->params['out_trade_no'] : '';
        if (empty($out_trade_no)) {
            return $this->outMessage($title, "", '-50', "缺少必填参数out_trade_no");
        }
        $order_query = new OrderQuery();
        $pay = new UnifyPay();
        $pay_value = $pay->getPayInfo($out_trade_no);
        $order_no = "";
        if ($pay_value['type'] == 1) {
            // 订单
            $order_no_result = $order_query->getOrderNoByOutTradeNo($out_trade_no);
            $order_no = empty($order_no_result['order_no']) ? "" : $order_no_result['order_no'];
        } elseif ($pay_value['type'] == 4) {
            // 余额充值不进行处理
        }
        return $this->outMessage($title, array(
            'order_no' => $order_no
        ));
    }
    
    /**
     * 获取支付方式配置信息
     * 创建时间:2022年2月20日10:33:26
     */
    public function getPayConfig()
    {
        $title = "获取支付方式配置信息";
        $pay = new UnifyPay();
        $res = $pay_config = $pay->getPayConfig();
        if (!empty($res)) {
            return $this->outMessage($title, $res);
        } else {
            return $this->outMessage($title, null, "-9999", "未获取到数据");
        }
    }
    
    /**
     * 余额支付选择界面
     */
    public function pay()
    {
        $title = '订单支付!';
        if (empty($this->uid)) {
            return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
        }
        $member = new MemberService();
        $pay = new UnifyPay();
        $config = new ConfigService();
        $uid = $member->getSessionUid();
        
        $out_trade_no = request()->post("out_trade_no", 0);
        
        // 支付信息
        $pay_value = $pay->getPayInfo($out_trade_no);
        
        if (empty($out_trade_no) || !is_numeric($out_trade_no) || empty($pay_value)) {
            return $this->outMessage($title, "", '-10', "没有获取到支付信息");
        }
        
        // 此次交易最大可用余额
        $member_balance = $pay->getMaxAvailableBalance($out_trade_no, $uid);
        $data["member_balance"] = $member_balance;
        
        $shop_id = 0;
        $shop_config = $config->getConfig($shop_id, "ORDER_BALANCE_PAY");
        
        // 支付方式配置
        $pay_config = $pay->getPayConfig();
        
        $order_status = $this->getOrderStatusByOutTradeNo($out_trade_no);
        // 订单关闭状态下是不能继续支付的
        if ($order_status == 5) {
            return $this->outMessage($title, "", '-10', "订单已关闭");
        }
        
        // 还需支付的金额
        $need_pay_money = round($pay_value['pay_money'], 2) - round($member_balance, 2);
        
        $zero1 = time(); // 当前时间 ,注意H 是24小时 h是12小时
        $zero2 = $pay_value['create_time'];
        $this->shop_config = $config->getShopConfig(0);
        
        $order_query = new OrderQuery();
        $order_info = $order_query->getOrderInfo([ "out_trade_no" => $out_trade_no ]);
        
        if ($zero1 > ($zero2 + ($this->shop_config['order_buy_close_time'] * 60)) && $order_info['order_type'] != 6 && $this->shop_config['order_buy_close_time'] != 0) {
            return $this->outMessage($title, "", '-10', "订单已关闭");
        } else {
            $data["pay_value"] = $pay_value;
            $data["need_pay_money"] = sprintf("%.2f", $need_pay_money);
            $data["shop_config"] = $shop_config;
            $data["pay_config"] = $pay_config;
            
            return $this->outMessage($title, $data);
        }
    }
    
    /**
     * 订单绑定余额 (若存在余额支付)
     */
    public function orderBindBalance()
    {
        $title = '余额支付';
        if (empty($this->uid)) {
            return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
        }
        $out_trade_no = isset($this->params['out_trade_no']) ? $this->params['out_trade_no'] : 0;
        $is_use_balance = isset($this->params['is_use_balance']) ? $this->params['is_use_balance'] : 0;
        $pay = new UnifyPay();
        $res = $pay->orderPaymentUserBalance($out_trade_no, $is_use_balance, $this->uid);
        return $this->outMessage($title, $res);
    }
    
    /**
     * 获取交易流水号
     */
    public function outTradeNo()
    {
        $title = '获取交易流水号';
        $pay = new UnifyPay();
        $out_trade_no = $pay->createOutTradeNo();
        return $this->outMessage($title, $out_trade_no);
    }
    
    /**
     * @return string
     */
    public function payInfo()
    {
        $title = '订单支付信息';
//         if (empty($this->uid)) {
//             return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
//         }
        $out_trade_no = isset($this->params['out_trade_no']) ? $this->params['out_trade_no'] : '';
        if (empty($out_trade_no)) {
            return $this->outMessage($title, "", '-10', "没有获取到支付信息");
        }
        
        $pay = new UnifyPay();
        $pay_info = $pay->getPayInfo($out_trade_no);
        return $this->outMessage($title, $pay_info);
    }
    
    /**
     * 可用最大余额
     * @return string
     */
    public function maxPayBalance()
    {
        $title = '订单支付信息';
        if (empty($this->uid)) {
            return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
        }
        $out_trade_no = isset($this->params['out_trade_no']) ? $this->params['out_trade_no'] : '';
        if (empty($out_trade_no)) {
            return $this->outMessage($title, "", '-10', "没有获取到支付信息");
        }
        $pay = new UnifyPay();
        $balance = $pay->getMaxAvailableBalance($out_trade_no, $this->uid);
        return $this->outMessage($title, [ "balance" => $balance ]);
    }
    
    /**
     * 订单在线支付
     * @return string
     */
    public function onlinePay()
    {
        $title = '订单支付';
        if (empty($this->uid)) {
            return $this->outMessage($title, "", '-9999', "无法获取会员登录信息");
        }
        $out_trade_no = $this->get('out_trade_no', '');
        $type = $this->get('type', '');
        $is_uniapp = $this->get('is_uniapp', 0);
        
        if (empty($type)) return $this->outMessage($title, "", '-9999', "没有获取到支付方式");
        
        $pay = new UnifyPay();
        $pay_value = $pay->getPayInfo($out_trade_no);
        if (empty($pay_value)) {
            return $this->outMessage($title, "", '-10', "没有获取到支付信息");
        }
        $order_status = $this->getOrderStatusByOutTradeNo($out_trade_no);
        // 订单关闭状态下是不能继续支付的
        if ($order_status == 5) {
            return $this->outMessage($title, "", '-10', "订单已关闭");
        }
        
        $config = new ConfigService();
        $zero1 = time(); // 当前时间 ,注意H 是24小时 h是12小时
        $zero2 = $pay_value['create_time'];
        $this->shop_config = $config->getShopConfig(0);
        
        $order_query = new OrderQuery();
        $order_info = $order_query->getOrderInfo([ "out_trade_no" => $out_trade_no ]);
        
        if ($zero1 > ($zero2 + ($this->shop_config['order_buy_close_time'] * 60)) && $order_info['order_type'] != 6 && $this->shop_config['order_buy_close_time'] != 0) {
            return $this->outMessage($title, "", '-10', "订单已关闭");
        }
        
        $base_url = str_replace("/index.php", "", __URL__);
        $base_url = str_replace("index.php", "", $base_url);
        $notify_url = $base_url . "/pay.php";
        $return_url = __URL(__URL__ . '/wap/Pay/payReturn');
        
        $openid = '';
        if (isWeixin() && $is_uniapp) {
            $third_party = new ThirdParty();
            $openid = $third_party->getOpenid('wxPublic', $this->uid);
        }
        
        $result = hook("pay", [ 'addon_name' => $type, 'out_trade_no' => $out_trade_no, 'notify_url' => $notify_url, 'return_url' => $return_url, 'is_uniapp' => $is_uniapp, 'openid' => $openid ]);
        $result = arrayFilter($result);
        $result = $result[0];
        
        return $this->outMessage($title, $result);
    }
    
    
    /**
     * 支付状态
     * @return string
     */
    public function payStatus()
    {
        $title = '获取支付状态';
        $out_trade_no = $this->get('out_trade_no', '');
        
        $pay = new UnifyPay();
        $pay_value = $pay->getPayInfo($out_trade_no);
        
        if (empty($pay_value)) {
            return $this->outMessage($title, "", '-10', "没有获取到支付信息");
        }
        
        if ($pay_value['pay_status'] > 0) {
            return $this->outMessage($title, $pay_value, 0, "支付成功");
        } else {
            return $this->outMessage($title, "", -1, "支付失败");
        }
    }
    
}

欢迎交流学习!

你可能感兴趣的:(nft)