tezos智能合约的合约间互相call

其实就是写一篇给自己打打气的,目前对于list当中的一系列迭代的inter contract invocation还是没能解决。记录一下不需要迭代的简单情况,如何实现吧。

//ligolang.org 
//重点就是ProxyApproval 另一个action 纯粹占位,可忽略。

type contract_storage is record
  creditor : address;
  payamount : nat;
end

type action is
| ProxyApproval
| AddCreditor of (address)

const exectAddress : address =
  ("KT1DdshqQRd8MSK4P57fyMtjQBuL6fVTpmgP" : address);

type parameter is
| Transfer of (address * address * nat)
| Approve of (address * nat)


function addCreditor (const store : contract_storage ; const creditor : address) : contract_storage is
block {
          const logging : contract_storage =
            record [
                creditor = ("tz1g4Kw2qhYELxeeHc2yiuLtPdovVckYNc6G" : address);
                payamount = 1000n;
            ];

}  with store


function proxyApproval (const store : contract_storage) : list(operation) * contract_storage is
  block {
    const execontract : contract (parameter) =
      case (Tezos.get_contract_opt (exectAddress) : option (contract (parameter))) of
        Some (contract) -> contract
      | None -> (failwith ("Contract not found.") : contract (parameter))
      end;
    const mock_param : parameter = Approve (store.creditor, store.payamount);
    const op : operation = Tezos.transaction (mock_param, 0tez, execontract);
    const ops : list (operation) = list [op]
  } with (ops,store)

function main (const p : action ; const s : contract_storage) :
  (list(operation) * contract_storage) is
 case p of 
  | ProxyApproval -> (proxyApproval(s))
  | AddCreditor (n) -> ((nil : list(operation)), addCreditor(s,n))
 end

喜大普奔,时隔两天之后,contract interaction within map iteration 解决了。中心思想是list(operation) 这玩意儿必须被返回到最上层,底下才会层层跑过去。

再次翻转,解决个毛线,还是没搞定loop中的inter-contract invocation。最后两个contracts 合并到了一个 再用loop。不开心!!!但是为了比赛交差,还是先给对,再来看做精的问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

取啥都被占用

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值