@ -1,4 +1,27 @@
var compile = function ( name ) { return web3 . eth . solidity ( env . contents ( "../../dapp-bin/" + name + "/" + name + ".sol" ) ) ; } ;
///TODO
var compile = function ( name ) { return web3 . eth . solidity ( env . contents ( "/home/gav/Eth/dapp-bin/" + name + "/" + name + ".sol" ) ) ; web3 . eth . flush ( ) ; } ;
var create = function ( code ) { return web3 . eth . transact ( { 'code' : code } ) ; web3 . eth . flush ( ) ; } ;
var createVal = function ( code , val ) { return web3 . eth . transact ( val ? { 'code' : code , 'value' : val } : { 'code' : code } ) ; web3 . eth . flush ( ) ; } ;
var send = function ( from , val , to ) { web3 . eth . transact ( { 'from' : from , 'value' : val , 'to' : to } ) ; web3 . eth . flush ( ) ; } ;
var initService = function ( name ) { return create ( compile ( name ) ) ; } ;
var initServiceVal = function ( name , val ) { createVal ( compile ( name ) , val ) ; } ;
var addrConfig = create ( compile ( "config" ) ) ;
var addrNameReg = initService ( "namereg" , addrConfig ) ;
var addrGavsino = initServiceVal ( "gavmble" , addrNameReg , "1000000000000000000" ) ;
var abiNameReg = [ { "constant" : true , "inputs" : [ { "name" : "name" , "type" : "string32" } ] , "name" : "addressOf" , "outputs" : [ { "name" : "addr" , "type" : "address" } ] } , { "constant" : false , "inputs" : [ ] , "name" : "kill" , "outputs" : [ ] } , { "constant" : true , "inputs" : [ { "name" : "addr" , "type" : "address" } ] , "name" : "nameOf" , "outputs" : [ { "name" : "name" , "type" : "string32" } ] } , { "constant" : false , "inputs" : [ { "name" : "name" , "type" : "string32" } ] , "name" : "register" , "outputs" : [ ] } , { "constant" : false , "inputs" : [ ] , "name" : "unregister" , "outputs" : [ ] } ] ;
var regName = function ( account , name ) { return web3 . eth . contract ( addrNameReg , abiNameReg ) . transact ( { 'from' : account , 'gas' : 10000 } ) . register ( name ) ; } ;
regName ( accounts [ 0 ] , 'Gav' ) ;
send ( web3 . eth . accounts [ 0 ] , '100000000000000000000' , web3 . eth . accounts [ 1 ] ) ;
regName ( accounts [ 1 ] , 'Gav Would' ) ;
/ *
// ASYNC API
var compile = function ( name ) { return web3 . eth . solidity ( env . contents ( "/home/gav/Eth/dapp-bin/" + name + "/" + name + ".sol" ) ) ; } ;
var create = function ( code ) { return web3 . eth . transact ( { 'code' : code } ) ; } ;
var create = function ( code ) { return web3 . eth . transact ( { 'code' : code } ) ; } ;
var createVal = function ( code , val ) { return web3 . eth . transact ( val ? { 'code' : code , 'value' : val } : { 'code' : code } ) ; } ;
var createVal = function ( code , val ) { return web3 . eth . transact ( val ? { 'code' : code , 'value' : val } : { 'code' : code } ) ; } ;
var send = function ( from , val , to ) { return web3 . eth . transact ( { 'from' : from , 'value' : val , 'to' : to } ) ; } ;
var send = function ( from , val , to ) { return web3 . eth . transact ( { 'from' : from , 'value' : val , 'to' : to } ) ; } ;
@ -11,13 +34,13 @@ var addrGavsino = initServiceVal("gavmble", addrNameReg, "1000000000000000000");
var abiNameReg = [ { "constant" : true , "inputs" : [ { "name" : "name" , "type" : "string32" } ] , "name" : "addressOf" , "outputs" : [ { "name" : "addr" , "type" : "address" } ] } , { "constant" : false , "inputs" : [ ] , "name" : "kill" , "outputs" : [ ] } , { "constant" : true , "inputs" : [ { "name" : "addr" , "type" : "address" } ] , "name" : "nameOf" , "outputs" : [ { "name" : "name" , "type" : "string32" } ] } , { "constant" : false , "inputs" : [ { "name" : "name" , "type" : "string32" } ] , "name" : "register" , "outputs" : [ ] } , { "constant" : false , "inputs" : [ ] , "name" : "unregister" , "outputs" : [ ] } ] ;
var abiNameReg = [ { "constant" : true , "inputs" : [ { "name" : "name" , "type" : "string32" } ] , "name" : "addressOf" , "outputs" : [ { "name" : "addr" , "type" : "address" } ] } , { "constant" : false , "inputs" : [ ] , "name" : "kill" , "outputs" : [ ] } , { "constant" : true , "inputs" : [ { "name" : "addr" , "type" : "address" } ] , "name" : "nameOf" , "outputs" : [ { "name" : "name" , "type" : "string32" } ] } , { "constant" : false , "inputs" : [ { "name" : "name" , "type" : "string32" } ] , "name" : "register" , "outputs" : [ ] } , { "constant" : false , "inputs" : [ ] , "name" : "unregister" , "outputs" : [ ] } ] ;
var regName = function ( account , name ) { return web3 . contract ( addrNameReg , abiNameReg ) . register ( name ) . transact ( { 'from' : account , 'gas' : 10000 } ) ; } ;
var regName = function ( account , name ) { return web3 . contract ( addrNameReg , abiNameReg ) . register ( name ) . transact ( { 'from' : account , 'gas' : 10000 } ) ; } ;
/ *
var coins = initService ( "coins" , 1 , nameReg ) ;
//var coins = initService("coins", 1, nameReg);
var coin = initService ( "coin" , 2 , coins ) ;
//var coin = initService("coin", 2, coins);
var approve = function ( account , approvedAddress ) { web3 . eth . transact ( { 'from' : account , 'to' : coin , 'gas' : '10000' , 'data' : [ web3 . fromAscii ( 'approve' ) , approvedAddress ] } ) ; } ;
//var approve = function(account, approvedAddress) { web3.eth.transact({ 'from': account, 'to': coin, 'gas': '10000', 'data': [ web3.fromAscii('approve'), approvedAddress ] }); };
var exchange = initService ( "exchange" , 3 , coin ) ;
//var exchange = initService("exchange", 3, coin);
var offer = function ( account , haveCoin , haveVal , wantCoin , wantVal ) { web3 . eth . transact ( { 'from' : account , 'to' : exchange , 'gas' : '10000' , 'data' : [ web3 . fromAscii ( 'new' ) , haveCoin , haveVal , wantCoin , wantVal ] } ) ; } ;
//var offer = function(account, haveCoin, haveVal, wantCoin, wantVal) { web3.eth.transact({ 'from': account, 'to': exchange, 'gas': '10000', 'data': [web3.fromAscii('new'), haveCoin, haveVal, wantCoin, wantVal] }); };
* /
addrConfig . then ( function ( ) {
addrConfig . then ( function ( ) {
env . note ( "config ready" ) ;
env . note ( "config ready" ) ;
web3 . eth . accounts . then ( function ( accounts )
web3 . eth . accounts . then ( function ( accounts )
@ -39,7 +62,7 @@ addrConfig.then(function() {
// eth.transact({ 'to': dnsReg, 'data': [web3.fromAscii('register'), web3.fromAscii('gav'), web3.fromAscii('opensecrecy.com')] });
// eth.transact({ 'to': dnsReg, 'data': [web3.fromAscii('register'), web3.fromAscii('gav'), web3.fromAscii('opensecrecy.com')] });
} ) ;
} ) ;
} ) ;
} ) ;
* /
// TODO
// TODO
/ *
/ *
var nameRegJeff ;
var nameRegJeff ;