Magician-ContractsTools

Magician-ContractsTools是一个Java智能合约调用工具包,支持ERC20、ERC721和ERC1155标准合约模板,提供查询和写入操作功能,未来还将支持自定义合约函数和多种区块链网络。

Check out Magician-ContractsTools on CurateClick

• Copy the embed code to showcase this product on your website

• Share on X to spread the word about this amazing tool

Magician-ContractsTools是一个用于调用智能合约的工具包,你可以非常容易地在Java程序中调用智能合约进行查询和写入操作。有三个内置的标准合约模板,分别是ERC20、ERC721和ERC1155,如果你需要调用这三个合约中的标准函数,可以帮助你非常快速地完成工作。除了内置的合同模板外,如果你需要调用自定义的合同函数也是很容易的,以后我们还会继续增加标准模板。此外,还有InputData解码和ETH查询和转移的工具计划支持三种链,ETH(BSC、POLYGON等)、SOL和TRONgithub地址: https://github.com/Magician-Blockchain/Magician-ContractsTools## 示例查询合约javaList<Type> result = ethContractUtil.select( contractAddress, // 合约地址 EthAbiCodecTool.getInputData( "balanceOf", // 要调用的方法名称 new Address(toAddress) // 方法的参数,如果有多个,可以继续传入下一个参数 ), // 要调用的方法的inputData new TypeReference<Uint256>() {} // 方法的返回类型,如果有多个返回值,可以继续传入下一个参数 );写入合约java// 往合约里写入数据SendResultModel sendResultModel = ethContractUtil.sendRawTransaction( SendModel.builder() .setSenderAddress("0xb4e32492E9725c3215F1662Cf28Db1862ed1EE84") // 调用者的地址 .setPrivateKey("")// senderAddress的私钥 .setToAddress(contractAddress) // 合约地址 .setValue(new BigInteger("1000000000")) // 主链币数量,如果想用默认值 可以直接传null,或者不传这个参数 .setGasPrice(new BigInteger("1000")) // gasPrice,如果想用默认值 可以直接传null,或者不传这个参数 .setGasLimit(new BigInteger("800000")) // gasLimit,如果想用默认值 可以直接传null,或者不传这个参数 EthAbiCodecTool.getInputData( "transfer", // 要调用的方法名称 new Address(toAddress), // 方法的参数,如果有多个,可以继续传入下一个参数 new Uint256(new BigInteger("1000000000000000000")) // 方法的参数,如果有多个,可以继续传入下一个参数 ) // 要调用的方法的inputData );sendResultModel.getEthSendTransaction(); // 发送交易后的结果sendResultModel.getEthGetTransactionReceipt(); // 交易成功上链后的结果合约模板(为了节约篇幅,这里只演示ERC20合约的部分函数)查询java// 调用合约的 totalSupply 函数BigInteger total = erc20Contract.totalSupply();// 调用合约的 balanceOf 函数BigInteger amount = erc20Contract.balanceOf("0xb4e32492E9725c3215F1662Cf28Db1862ed1EE84");// 调用合约的 allowance 函数BigInteger amount = erc20Contract.allowance("0xb4e32492E9725c3215F1662Cf28Db1862ed1EE84", "0x552115849813d334C58f2757037F68E2963C4c5e");写入java// 调用合约的 transfer 函数SendResultModel sendResultModel = erc20Contract.transfer( "0x552115849813d334C58f2757037F68E2963C4c5e", // 转账接收人 new BigInteger("1000000000000000000"), // 转账金额 SendModel.builder() .setSenderAddress("0xb4e32492E9725c3215F1662Cf28Db1862ed1EE84") // 调用者的地址 .setPrivateKey("")// senderAddress的私钥 .setValue(new BigInteger("1000000000")) // 主链币数量,如果想用默认值 可以直接传null,或者不传这个参数 .setGasPrice(new BigInteger("1000")) // gasPrice,如果想用默认值 可以直接传null,或者不传这个参数 .setGasLimit(new BigInteger("800000")) // gasLimit,如果想用默认值 可以直接传null,或者不传这个参数 );sendResultModel.getEthSendTransaction(); // 发送交易后的结果sendResultModel.getEthGetTransactionReceipt(); // 交易成功上链后的结果

Latest Weekly Picks

make.ink favicon
Weekly Pick

Your AI tattoo generator for pro-grade concepts

Leo Wade
sellfy.com favicon
Weekly Pick

A code-free online store builder to turn views into revenue. Sell digital products, subscriptions, and merch, without fees or hassle.

Maris
www.videotoblog.ai favicon
Weekly Pick

Convert videos into awesome blog posts.

Video To Blog
www.sellerpic.ai favicon
Weekly Pick

SellerPic is the all-in-one AI design platform for e-commerce

SellerPic
fastimage.ai favicon
Weekly Pick

Fast Image AI instantly transforms your photos into stunning styles like Ghibli, Sketch, and Pixar. Effortlessly control image elements and create amazing effects with just one click.

Fast AI Team
linkedinpro.daisy.so favicon
Weekly Pick

AI-powered tool that transforms casual photos into professional LinkedIn headshots instantly. No photographer needed—just upload and download.

Gabriel
crevas.ai favicon
Weekly Pick

Crevas unifies Veo 3, Sora 2, Nano Banana and more into one intuitive canvas — so filmmakers can script, prompt, and generate cinematic stories without switching tools or losing consistency.

Spark Alpha
fotominiatur.com favicon
Weekly Pick

AI Foto Edit - Text to Image & Image Edit

foto miniatur