当前位置:网站首页>第92篇 合约间调用(一)
第92篇 合约间调用(一)
2022-07-21 10:37:00 【wonderBlock】
本文环境:以太坊POA联盟链 + MetaMask + Remix
1.方法
本文介绍“接口直接调用法”,实现合约对合约的调用;
这种方式调用,是最简单方便的调用方式,缺点是只能调用固定的接口,不够灵活。
以下是调用一个已经部署的合约的 deposit 方法。
pragma solidity ^0.5.10;
interface ContractInterface {
function deposit(string calldata _name) external payable returns(bool);
}
contract InterfaceCall {
function callDeposit(address _contract, string memory _args)
public
returns(bool)
{
ContractInterface ci = ContractInterface(_contract);
bool retValue = ci.deposit(_args);
return retValue;
}
}
2.示例
2.1 contractA.sol
pragma solidity^0.5.0;
contract contractA {
uint randNonce = 0;
uint randomN;
address owner;
mapping(address => bool) public minters;
// 修饰器,管理员权限
modifier onlyMinter() {
require(minters[msg.
边栏推荐
- 游戏代码规范实例之单例
- Array / slice of go
- MySQL creates new users and authorizes them
- "If..." Rudyard Kipling
- How to make the demand unable to go online smoothly as scheduled (I) overall strategy
- Instrumentation, three-phase ammeter LCD segment code LCD low-power anti-interference drive ic-vk2c23a/b (dic/cob can be output)
- 特征抽取工具-Transformer-bert
- Neural network GCNN of drawing machine
- 极化SAR——极化椭圆
- Dynamically generate excel forms in word documents (explanation of Fund announcement Series)
猜你喜欢
决策树_ID3_C4.5_CART
Alibaba cloud technology expert Yang Zeqiang: building observable capabilities on elastic computing cloud
Batch efficient feature decomposition of eccv2022 small and medium-sized matrices
LeetCode652 寻找重复的子树
隐马尔科夫模型 HMM
ECCV 2022 | multi domain long tailed distributed learning to solve the problem of unbalanced domain generalization
Alibaba Cloud Toolkit一键自动部署jar包
js教程实践(JS基础)
String类常用方法
[JS reverse hundred examples] a public resource trading network, reverse analysis of announcement URL parameters
随机推荐
游戏中的数学之3D基础
Solution to the offset of Gaode map positioning on GeoServer layer
第104篇 Compound 中的 cTokens
Policy mode rewriting if else advanced use
Stream stream filters the list set for duplicate fields
Addition and subtraction of C super integer
怎样才能让需求无法如期顺利上线(二)需求阶段
问一下REITs是什么呢?请问,手机开户股票开户安全吗?
怎样才能让需求无法如期顺利上线(五)业务验收阶段
第105篇 Compound 中的 Comptroller
我的创作纪念日
阿里云技术专家杨泽强:弹性计算云上可观测能力构建
方舟编译器来了,APK加固还怎么搞
Self defined multiple code of station B
Learning foundation - word memory
Day 9 (this关键字与实验)
极化SAR——极化椭圆
怎样才能让需求无法如期顺利上线(四)集成测试阶段
策略模式改写if else 高级使用
Tensorflow serving deployment tensorflow, keras model details