スマートコントラクトのデプロイから実行まで /Solidity Smart Contracts in Truffle

LIST OF LINKS------

Truffle Site: http://truffleframework.com/

List of Official Tutorials: http://truffleframework.com/tutorials/

Basic: https://qiita.com/toshikase/items/d313b7c28bf16b940b12

http://truffleframework.com/tutorials/debugging-a-smart-contract

 

Tutorial: SimpleStorage.sol

newest: http://truffleframework.com/tutorials/debugging-a-smart-contract

https://medium.com/@gus_tavo_guim/using-truffle-to-create-and-deploy-smart-contracts-95d65df626a2

 

Tutorial: MetaCoin.sol http://truffleframework.com/docs/getting_started/contracts#reading-amp-writing-data

Code: calculator https://ethereum.stackexchange.com/questions/15704/how-to-get-return-value-of-function-for-solidity-contract 

Tutorial: PoExistance https://ethereum.stackexchange.com/questions/25131/deploying-smart-contract-on-testrpc-with-truffle

 

Tutorial: SimpleStorage.sol------

1: set files: sol, migration

2: in Terminal, following:

truffle compile

truffle migrate

truffle console

3: in console:

truffle(development)> SimpleStorage.deployed().then(function(instance){return instance.get.call();}).then(function(value){return value.toNumber()});

CHECK: result is 0.

 

truffle(development)> SimpleStorage.deployed().then(function(instance){return instance.set(4);});

undefined

truffle(development)> SimpleStorage.deployed().then(function(instance){return instance.get.call();}).then(function(value){return value.toNumber()});

 

Truffle migrateをしても "Error: -- has not been deployed"となる場合:

状況:

(1) truffleでのcompileとmigrateは成功

➜ truffle_minernode1 truffle migrate
Using network 'development'.

Network up to date.

(2) truffle consoleでは、ネットワークにdeployされていないと言われる
truffle(development)> SimpleStorage.deployed()
Error: SimpleStorage has not been deployed to detected network (network/artifact mismatch)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:299260:17
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
truffle(development)> SimpleStorag
ReferenceError: SimpleStorag is not defined
at evalmachine.<anonymous>:1:1
...

 

解決策: buildファイルの中の全てのJSONファイルを削除

再度 compile & migrateすると成功。