tezos智慧型合約的合約間互相call

2021-10-06 18:56:49 字數 1045 閱讀 4251

其實就是寫一篇給自己打打氣的,目前對於list當中的一系列迭代的inter contract invocation還是沒能解決。記錄一下不需要迭代的簡單情況,如何實現吧。

type contract_storage is record

creditor : address;

payamount : nat;

endtype action is

| addcreditor of (address)

const exectaddress : address =

("kt1ddshqqrd8msk4p57fymtjqbul6fvtpmgp" : address);

type parameter is

| transfer of (address * address * nat)

function addcreditor (const store : contract_storage ; const creditor : address) : contract_storage is

block with store

block with (ops,store)

function main (const p : action ; const s : contract_storage) :

(list(operation) * contract_storage) is

case p of

| addcreditor (n) -> ((nil : list(operation)), addcreditor(s,n))

end

喜大普奔,時隔兩天之後,contract interaction within map iteration 解決了。中心思想是list(operation) 這玩意兒必須被返回到最上層,底下才會層層跑過去。

再次翻轉,解決個毛線,還是沒搞定loop中的inter-contract invocation。最後兩個contracts 合併到了乙個 再用loop。不開心!!!但是為了比賽交差,還是先給對,再來看做精的問題。

編寫智慧型合約

1.安裝node.js 2.安裝truffle npm install g truffle 3.啟動testrpc以太坊環境 testrpc 4.另開終端視窗新建專案 mkdir demo cd demo 5.初始化專案目錄 truffle init 6.建立合約檔案 truffle create ...

積分智慧型合約

pragma solidity 0.4.22 title safemath dev math operations with safety checks that throw on error library safemath function div uint256 a,uint256 b int...

部署智慧型合約

合約部署需要挖礦才能成功,我們新開乙個視窗用與挖礦,新開乙個控制台,輸入命令 geth attach 連線到控制台,執行miner.start 1 開始挖礦。合約demo如下 pragma solidity 0.4.0 contract infocontract function getinfo p...