Blockwell

Dentacoin

ERC20

This contract is an ERC20 token.

Name Dentacoin
Symbol ٨
Decimals 0
Total Supply 8,000,000,000,000 ٨

About link description

Dentacoin ( DCN ) is a blockchain solution for the global dental industry. It is developing a new dental ecosystem with the following goals: - Make preventive dental care affordable to people with lower costs and/or no private insurances - through Dentacoin Assurance; - Help people improve their oral hygiene habits through a dedicated app - Dentacare; - Provide market data about patients’ opinions/needs through DentaVox surveys; - Deliver the infrastructure for trusted and detailed patient feedback for dentists to improve upon - Dentacoin Trusted Reviews; - Secure and ease all payments while reducing transaction costs through an industry-specific cryptocurrency (Dentacoin) and the Dentacoin Wallet dApp.

Stats

Public Functions 17
Event Types 2
Code Size 13,892 bytes

Approval Event

Parameters help
_owner
address help
_spender
address help
_value
uint256 help

Transfer Event

Parameters help
_from
address help
_to
address help
_value
uint256 help

Functions Expand All Collapse All

balanceOf keyboard_arrow_up

Parameters help

Name Type
_owner
address help

Properties

Visibility help public
Mutability help constant
Source Code
    function balanceOf(address _owner) constant returns (uint256 balance) {
        return balances[_owner];
    }

transfer keyboard_arrow_up

Parameters help

Name Type
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function transfer(address _to, uint256 _value) returns (bool success) {
        if (_value < DCNForGas) throw;                                      // Prevents drain and spam
        if (msg.sender != owner && _to == DentacoinAddress && directTradeAllowed) {
            sellDentacoinsAgainstEther(_value);                             // Trade Dentacoins against eth by sending to the token contract
            return true;
        }

        if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {               // Check if sender has enough and for overflows
            balances[msg.sender] = safeSub(balances[msg.sender], _value);   // Subtract DCN from the sender

            if (msg.sender.balance >= minBalanceForAccounts && _to.balance >= minBalanceForAccounts) {    // Check if sender can pay gas and if recipient could
                balances[_to] = safeAdd(balances[_to], _value);             // Add the same amount of DCN to the recipient
                Transfer(msg.sender, _to, _value);                          // Notify anyone listening that this transfer took place
                return true;
            } else {
                balances[this] = safeAdd(balances[this], DCNForGas);        // Pay DCNForGas to the contract
                balances[_to] = safeAdd(balances[_to], safeSub(_value, DCNForGas));  // Recipient balance -DCNForGas
                Transfer(msg.sender, _to, safeSub(_value, DCNForGas));      // Notify anyone listening that this transfer took place

                if(msg.sender.balance < minBalanceForAccounts) {
                    if(!msg.sender.send(gasForDCN)) throw;                  // Send eth to sender
                  }
                if(_to.balance < minBalanceForAccounts) {
                    if(!_to.send(gasForDCN)) throw;                         // Send eth to recipient
                }
            }
        } else { throw; }
    }

transferFrom keyboard_arrow_up

Parameters help

Name Type
_from
address help
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
        //same as above. Replace this line with the following if you want to protect against wrapping uints.
        if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
        //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
            balances[_from] -= _value;
            balances[_to] += _value;
            allowed[_from][msg.sender] -= _value;
            Transfer(_from, _to, _value);
            return true;
        } else { return false; }
    }

approve keyboard_arrow_up

Parameters help

Name Type
_spender
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function approve(address _spender, uint256 _value) returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
        return true;
    }

allowance keyboard_arrow_up

Parameters help

Name Type
_owner
address help
_spender
address help

Properties

Visibility help public
Mutability help constant
Source Code
    function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
      return allowed[_owner][_spender];
    }

transferOwnership keyboard_arrow_up

Parameters help

Name Type
newOwner
address help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
    function transferOwnership(address newOwner) onlyOwner {
        if (newOwner == 0x0) throw;
        owner = newOwner;
    }

setEtherPrices keyboard_arrow_up

Parameters help

Name Type
newBuyPriceEth
uint256 help
newSellPriceEth
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setEtherPrices(uint256 newBuyPriceEth, uint256 newSellPriceEth) onlyOwner {
        buyPriceEth = newBuyPriceEth;                                       // Set prices to buy and sell DCN
        sellPriceEth = newSellPriceEth;
    }

setGasForDCN keyboard_arrow_up

Parameters help

Name Type
newGasAmountInWei
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setGasForDCN(uint newGasAmountInWei) onlyOwner {
        gasForDCN = newGasAmountInWei;
    }

setDCNForGas keyboard_arrow_up

Parameters help

Name Type
newDCNAmount
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setDCNForGas(uint newDCNAmount) onlyOwner {
        DCNForGas = newDCNAmount;
    }

setGasReserve keyboard_arrow_up

Parameters help

Name Type
newGasReserveInWei
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setGasReserve(uint newGasReserveInWei) onlyOwner {
        gasReserve = newGasReserveInWei;
    }

setMinBalance keyboard_arrow_up

Parameters help

Name Type
minimumBalanceInWei
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setMinBalance(uint minimumBalanceInWei) onlyOwner {
        minBalanceForAccounts = minimumBalanceInWei;
    }

haltDirectTrade keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
    function haltDirectTrade() onlyOwner {
        directTradeAllowed = false;
    }

unhaltDirectTrade keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
    function unhaltDirectTrade() onlyOwner {
        directTradeAllowed = true;
    }

buyDentacoinsAgainstEther keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
    function buyDentacoinsAgainstEther() payable returns (uint amount) {
        if (buyPriceEth == 0 || msg.value < buyPriceEth) throw;             // Avoid dividing 0, sending small amounts and spam
        amount = msg.value / buyPriceEth;                                   // Calculate the amount of Dentacoins
        if (balances[this] < amount) throw;                                 // Check if it has enough to sell
        balances[msg.sender] = safeAdd(balances[msg.sender], amount);       // Add the amount to buyer's balance
        balances[this] = safeSub(balances[this], amount);                   // Subtract amount from Dentacoin balance
        Transfer(this, msg.sender, amount);                                 // Execute an event reflecting the change
        return amount;
    }

sellDentacoinsAgainstEther keyboard_arrow_up

Parameters help

Name Type
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
    function sellDentacoinsAgainstEther(uint256 amount) returns (uint revenue) {
        if (sellPriceEth == 0 || amount < DCNForGas) throw;                 // Avoid selling and spam
        if (balances[msg.sender] < amount) throw;                           // Check if the sender has enough to sell
        revenue = safeMul(amount, sellPriceEth);                            // Revenue = eth that will be send to the user
        if (safeSub(this.balance, revenue) < gasReserve) throw;             // Keep min amount of eth in contract to provide gas for transactions
        if (!msg.sender.send(revenue)) {                                    // Send ether to the seller. It's important
            throw;                                                          // To do this last to avoid recursion attacks
        } else {
            balances[this] = safeAdd(balances[this], amount);               // Add the amount to Dentacoin balance
            balances[msg.sender] = safeSub(balances[msg.sender], amount);   // Subtract the amount from seller's balance
            Transfer(this, msg.sender, revenue);                            // Execute an event reflecting on the change
            return revenue;                                                 // End function and returns
        }
    }

refundToOwner keyboard_arrow_up

Parameters help

Name Type
amountOfEth
uint256 help
dcn
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function refundToOwner (uint256 amountOfEth, uint256 dcn) onlyOwner {
        uint256 eth = safeMul(amountOfEth, 1 ether);
        if (!msg.sender.send(eth)) {                                        // Send ether to the owner. It's important
            throw;                                                          // To do this last to avoid recursion attacks
        } else {
            Transfer(this, msg.sender, eth);                                // Execute an event reflecting on the change
        }
        if (balances[this] < dcn) throw;                                    // Check if it has enough to sell
        balances[msg.sender] = safeAdd(balances[msg.sender], dcn);          // Add the amount to buyer's balance
        balances[this] = safeSub(balances[this], dcn);                      // Subtract amount from seller's balance
        Transfer(this, msg.sender, dcn);                                    // Execute an event reflecting the change
    }

constructor keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
    function() payable {
        if (msg.sender != owner) {
            if (!directTradeAllowed) throw;
            buyDentacoinsAgainstEther();                                    // Allow direct trades by sending eth to the contract
        }
    }