1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| truffle console #console 内 truffle(development)> Calc. Calc.__defineGetter__ Calc.__defineSetter__ Calc.__lookupGetter__ Calc.__lookupSetter__ Calc.__proto__ Calc.constructor Calc.hasOwnProperty Calc.isPrototypeOf Calc.propertyIsEnumerable Calc.toLocaleString Calc.toString Calc.valueOf Calc.apply Calc.arguments Calc.bind Calc.call Calc.caller Calc.length Calc.name Calc._json Calc._properties Calc._property_values Calc._static_methods Calc.abi Calc.addProp Calc.address Calc.ast Calc.at Calc.binary Calc.bytecode Calc.class_defaults Calc.clone Calc.compiler Calc.contractName Calc.contract_name Calc.currentProvider Calc.defaults Calc.deployed Calc.deployedBinary Calc.deployedBytecode Calc.deployedSourceMap Calc.detectNetwork Calc.events Calc.hasNetwork Calc.isDeployed Calc.link Calc.links Calc.network Calc.network_id Calc.networks Calc.new Calc.prototype Calc.resetAddress Calc.schemaVersion Calc.schema_version Calc.setNetwork Calc.setProvider Calc.source Calc.sourceMap Calc.sourcePath Calc.toJSON Calc.unlinked_binary Calc.updatedAt Calc.updated_at Calc.web3 #合约对象相关的信息 #查看部署的信息 Calc.defaults() #获取当前抽象实例的信息,除此之外,还有 at(), new()方法用不同的方式来获取其他实例。 Migrations.deployed() # 因为这个 deployed() 的返回值被 promise 化了,所以一切都应该按照回调来考虑 var a; # 准备一个可赋值的变量,用 then 来赋值。 Calc.deployed().then(function(instance) { a = instance}) # 生成可复用的 abi 字符串。记得在使用时去掉单引号。 JSON.stringify(a.abi) a.owner(); # 返回一个事务对象 truffle(development)> a.realAdd(11, 2) { tx: '0xcd5e32ee51a3289272660ad154e7057d25b972f65633d6c8bbe64ba9795ee062', receipt: { blockHash: '0x6e1960bab1b3cb3f3f0b877a799f3561c23c2345d129efca339d8e3bdc9f6ca7', blockNumber: 15886, contractAddress: null, cumulativeGasUsed: 22009, from: 'bbb', gasUsed: 22009, logs: [], logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', root: '0x2f405095a81a2a59dc2ba47a37e21d4f1ef839d64fe92c00c9bc18e2af7f1898', to: '0x50361da49a229247381c8d920853aa5560f8608c', transactionHash: '0xcd5e32ee51a3289272660ad154e7057d25b972f65633d6c8bbe64ba9795ee062', transactionIndex: 0 }, logs: [] } truffle(development)> { tx: '0xf493659cbbc3202236e8876fe8b2908760c9393fcdbcafe6d33c0a3e78220493', receipt: { blockHash: '0x6e1960bab1b3cb3f3f0b877a799f3561c23c2345d129efca339d8e3bdc9f6ca7', blockNumber: 15886, contractAddress: null, cumulativeGasUsed: 44018, from: 'bbb', gasUsed: 22009, logs: [], logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', root: '0x4b437a56092089c92564ca3255555b306ca0ab703b460287aa05ff79e12daeb1', to: '0x50361da49a229247381c8d920853aa5560f8608c', transactionHash: '0xf493659cbbc3202236e8876fe8b2908760c9393fcdbcafe6d33c0a3e78220493', transactionIndex: 1 }, logs: [] } # 直接用 call 调用 a.realAdd.call(11, 2) BigNumber { s: 1, e: 1, c: [ 13 ] } a.add.call(1, 2) BigNumber { s: 1, e: 0, c: [ 3 ] } # 事务调用 a.add.sendTransaction(1, 2, {from: 'bbb'}) # 查看预估的 gas 消耗 a.add.estimateGas()
|