An Ethereum Smart Contract that will allow your contracts to get up-to-date ETH/USD, ETH/EUR, and ETH/GBP prices. Using this contract doesn't require any contract calls or any extra setup. Many people ask how to get the rate of ETH in USD from within a contract, fiat contract is here to do this for you. This smart contract doesn't only do USD, but it also lets you use EURO, and GBP.
An Ethereum Smart Contract that will allow your contracts to get up-to-date ETH/USD, ETH/EUR, and ETH/GBP prices. Using this contract doesn't require any contract calls or any extra setup. Using solidity you can use the testnet or use the mainnet to get current crypto prices.
price = FiatContract(0x8055d0504666e2B6942BeB8D6014c964658Ca591) // MAINNET ADDRESS price = FiatContract(0x2CDe56E5c8235D6360CCbb0c57Ce248Ca9C80909) // TESTNET ADDRESS (ROPSTEN)
This is a full example of an Ethereum Smart Contract using Fiat Contract. This contract as a function "DoCall()" that requires $5.00 USD in Ether.
pragma solidity ^0.4.15; contract FiatContract { function ETH(uint _id) constant returns (uint256); function USD(uint _id) constant returns (uint256); function EUR(uint _id) constant returns (uint256); function GBP(uint _id) constant returns (uint256); function updatedAt(uint _id) constant returns (uint); } contract Example { FiatContract public price; event NewPayment(address sender, uint256 amount); function Example() { price = FiatContract(0x8055d0504666e2B6942BeB8D6014c964658Ca591); } // returns $5.00 USD in ETH wei. function FiveETHUSD() constant returns (uint256) { // returns $0.01 ETH wei uint256 ethCent = price.USD(0); // $0.01 * 500 = $5.00 return ethCent * 500; } function DoCall() external payable returns (string) { require(msg.value==FiveETHUSD()); NewPayment(msg.sender, msg.value); return "you paid $5.00 USD!!!"; } }
eth = price.USD(0); // this will respond $0.01 USD worth of ETH btc = price.USD(1); // PENDING - this will respond $0.01 USD worth of BITCOIN (converted into ETH) ltc = price.USD(2); // PENDING - this will respond $0.01 USD worth of LITECOIN (converted into ETH) omg = price.USD(4); // PENDING - this will respond $0.01 USD worth of OMISEGO (converted into ETH) eos = price.USD(5); // PENDING - this will respond $0.01 USD worth of EOS (converted into ETH) tex = price.USD(6); // PENDING - this will respond $0.01 USD worth of TENX (converted into ETH) rep = price.USD(7); // PENDING - this will respond $0.01 USD worth of AUGUR (converted into ETH) qtm = price.USD(8); // PENDING - this will respond $0.01 USD worth of QTUM (converted into ETH) bat = price.USD(9); // PENDING - this will respond $0.01 USD worth of GOLEM (converted into ETH) zrx = price.USD(10); // PENDING - this will respond $0.01 USD worth of OXPROJECT (converted into ETH) sts = price.USD(11); // PENDING - this will respond $0.01 USD worth of STATUS (converted into ETH) ban = price.USD(12); // PENDING - this will respond $0.01 USD worth of BANCOR (converted into ETH)Some cryptocurrencies are not inserted into the Fiat Contract yet. Since we update each crypto every hour, we need donations to help support the gas costs.
USDcent = price.USD(0); // this will respond $0.01 USD worth of ETH EUROcent = price.EUR(0); // this will respond $0.01 EURO worth of ETH GBPcent = price.GBP(0); // this will respond $0.01 GBP worth of ETH oneDollar = USDcent * 100; // value is $1.00 USD in ETH fiveDollars = USDcent * 500; // value is $5.00 USD in ETH sevenEuros = EUROcent * 700; // value is $7.00 EURO in ETH tenPounds = GBPcent * 1000; // value is $10.00 GBP in ETH oneBTC = price.ETH(1); // this will respond amount of ETH for 1 BITCOIN oneLTC = price.ETH(2); // this will respond amount of ETH for 1 LITECOIN threeBTC = oneBTC * 3; // responds the value of 3 Bitcoin in ETH.
Fiat Contract is updated every 1 hour on the Ethereum Mainnet blockchain. Doing all these contract calls require gas to be spent which is in ETH. The contract is supported by blockchainers that use this contract to easily fetch USD, EURO, GBP conversions.
Donate ETH to address: 0x004F3E7fFA2F06EA78e14ED2B13E87d710e8013F