数字经济是以数据资源为关键要素,以数字科技为支撑的经济形态。数字产业化和产业数字化是数字经济中的重点内容,数字产业化主要是推动数字科技形成规模化产业,
产业数字化主要是利用数字科技支撑和推动传统产业转型升级。在这个过程中可以基于区块链等数字科技推动信息技术服务加速数字产业化,依托元宇宙的新场景拉动信息消费促进产业数字化。
contract ERC721{
function balanceOf(address _owner)external view returns(uint256);
function ownerOf(uint256 _tokenId)external view returns(address);
function safeTransferFrom(address _from,address _to,uint256 _tokenId,bytes data)external payable;
function safeTransferFrom(address _from,address _to,uint256 _tokenId)external payable;
function transferFrom(address _from,address _to,uint256 _tokenId)external payable;
function approve(address _approved,uint256 _tokenId)external payable;
function setApprovalForAll(address _operator,bool _approved)external;
function getApproved(uint256 _tokenId)external view returns(address);
function isApprovedForAll(address _owner,address _operator)external view returns(bool);
function supportsInterface(bytes4 interfaceID)external view returns(bool);
event Transfer(address indexed _from,address indexed _to,uint256 _tokenId);
event Approval(address indexed _owner,address indexed _approved,uint256 _tokenId);
event ApprovalForAll(address indexed _owner,address indexed _operator,bool _approved);
}
Python Web3与智能合约的交互
开发合约,或者开源合约,都会有一份该合约的ABI JSON文件
ABI文件包括了智能合约的输入与输出格式(其中name对应合约function的名字)
from web3 import Web3
import web3
CONTRACT='0x22C1f6050E56d2876009903609a2cC3fEf83B415'#合约地址
HTTPProvider="https://dai.poa.network"#主网HttpProvider
#---打开abi json文件
with open('contracts/contract_abi.json','r')as contract_abi:
abi=json.load(contract_abi)
#---提供HTTPProvider,链上互动的接口
w3=Web3(Web3.HTTPProvider(HTTPProvider))
#---检查HTTPProvider
print(w3.isConnected())
#---继续
#---连接合约
contract=w3.eth.contract(address=CONTRACT,abi=abi)