Ask Ξ Community: What do you think of our new smart contract, PriceFeed?

romanmromanm Member Posts: 37
edited September 2015 in Projects
Hey Ether Enthusiasts,

We have designed a bot that pumps real market values
into an Ethereum smart contract, you can see it here:

http://feed.ether.camp

Now you have the option to build new Ethereum smart contracts on top
of real world values. If you prefer to work in a trust-less environment we
will show you how you can create your own bot that will do it based upon
your variables.

What do you think ? (back to reddit comments)

===========================

How to access it from your own contract ?
All you need is couple of lines of code:
PriceFeedApi priceFeed = PriceFeedApi(named("ether-camp/price-feed"));
uint price = priceFeed.getPrice("USDT_ETH")

and the contract interface:
contract PriceFeedApi {
    
    function getPrice(bytes32 symbol) returns(uint currPrice);  
    function getTimestamp(bytes32 symbol) returns(uint timestamp);
}
[available symbols]
USDT_ETH, BTC_ETH, USDT_BTC,
EURUSD, GBPUSD, USDJPY, XAUUSD,
XAGUSD SP500, NASDAQ, AAPL, GOOG,
MSFT, GM, GE, WMT, F, T

Full invoke sample is here:
https://github.com/ether-camp/contracts/blob/master/PriceTest.sol


What do you think ? (back to reddit comments)

===================================================================

How to access it from your own web3 page ?
	 	 

       factory.price = function(symbol, callback) {
	 
	    var web3 = require('web3');                        
			
	    // you can set your own peer to handle this 
	    web3.setProvider(new web3.providers.HttpProvider('http://lb-frontier.ether.camp'));	 
			
	    var nameRegAbi = [{"constant":true,
			            "inputs"[{"name":"name","type":"bytes32"}],"name":"addressOf",
						"outputs":[{"name":"addr","type":"address"}],"type":"function"}];
  		    
            var nrAddress = "0x985509582b2c38010bfaa3c8d2be60022d3d00da";
            var Namereg = web3.eth.contract(nameRegAbi).at(nrAddress);
			
	    Namereg.addressOf.call("ether-camp/price-feed", function(err, pfAddress){            
			
	     var priceFeedAbi = [{"constant":true,
		         "inputs":
                            [{"name":"symbol","type":"bytes32"}],
                              "name":"getPrice",
			 "outputs":[{"name":"currPrice","type":"uint256"}],
                               "type":"function"},
			{"constant":true,"inputs":[{"name":"symbol","type":"bytes32"}],
                                "name":"getTimestamp",
			 "outputs":[{"name":"timestamp","type":"uint256"}],
                                "type":"function"}];
	     var PriceFeed = web3.eth.contract(priceFeedAbi).at(pfAddress);				
			
	     PriceFeed.getPrice.call(symbol, callback);						 	 		
	  });
}
[available symbols]
USDT_ETH, BTC_ETH, USDT_BTC,
EURUSD, GBPUSD, USDJPY, XAUUSD,
XAGUSD SP500, NASDAQ, AAPL, GOOG,
MSFT, GM, GE, WMT, F, T


What do you think ? (back to reddit comments)



P.S. on the open source ethereum bot , will post latter. we will post the open-source ethereum bot later




With love from
ether.camp



Comments

Sign In or Register to comment.