# Path: hydrachain/nc_utils.py
# def isaddress(x):
#     return len(x) == 20 and x != '\0' * 20
# 
# STATUS = 'uint16'
# 
# FORBIDDEN = 403
# 
# OK = 200
# 
# INSUFFICIENTFUNDS = PAYMENTREQUIRED = 402


import ethereum.utils as utils
import ethereum.slogging as slogging
import hydrachain.native_contracts as nc
from hydrachain.nc_utils import isaddress, STATUS, FORBIDDEN, OK, INSUFFICIENTFUNDS
        ctx.owner = ctx.tx_origin
        ctx.accounts[ctx.tx_origin] = _supply
        ctx.supply = _supply
        return OK

    def transfer(ctx, _to='address', _value='uint256', returns=STATUS):
        """ Standardized Contract API:
        function transfer(address _to, uint256 _value) returns (bool _success)
        """
        log.DEV('In Fungible.transfer')
        if ctx.accounts[ctx.msg_sender] >= _value:
            ctx.accounts[ctx.msg_sender] -= _value
            ctx.accounts[_to] += _value
            ctx.Transfer(ctx.msg_sender, _to, _value)
            return OK
        else:
            return INSUFFICIENTFUNDS

    def transferFrom(ctx, _from='address', _to='address', _value='uint256', returns=STATUS):
        """ Standardized Contract API:
        function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
        """
        auth = ctx.allowances[_from][ctx.msg_sender]
        if ctx.accounts[_from] >= _value and auth >= _value:
            ctx.allowances[_from][ctx.msg_sender] -= _value
            ctx.accounts[_from] -= _value
            ctx.accounts[_to] += _value
            ctx.Transfer(_from, _to, _value)
            return OK
        else:

# Path: hydrachain/nc_utils.py
# def isaddress(x):
#     return len(x) == 20 and x != '\0' * 20
# 
# STATUS = 'uint16'
# 
# FORBIDDEN = 403
# 
# OK = 200
# 
# INSUFFICIENTFUNDS = PAYMENTREQUIRED = 402


# Path: hydrachain/examples/native/fungible/fungible_contract.py
import ethereum.utils as utils
import ethereum.slogging as slogging
import hydrachain.native_contracts as nc
from hydrachain.nc_utils import isaddress, STATUS, FORBIDDEN, OK, INSUFFICIENTFUNDS

        ctx.owner = ctx.tx_origin
        ctx.accounts[ctx.tx_origin] = _supply
        ctx.supply = _supply
        return OK

    def transfer(ctx, _to='address', _value='uint256', returns=STATUS):
        """ Standardized Contract API:
        function transfer(address _to, uint256 _value) returns (bool _success)
        """
        log.DEV('In Fungible.transfer')
        if ctx.accounts[ctx.msg_sender] >= _value:
            ctx.accounts[ctx.msg_sender] -= _value
            ctx.accounts[_to] += _value
            ctx.Transfer(ctx.msg_sender, _to, _value)
            return OK
        else:
            return INSUFFICIENTFUNDS

    def transferFrom(ctx, _from='address', _to='address', _value='uint256', returns=STATUS):
        """ Standardized Contract API:
        function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
        """
        auth = ctx.allowances[_from][ctx.msg_sender]
        if ctx.accounts[_from] >= _value and auth >= _value:
            ctx.allowances[_from][ctx.msg_sender] -= _value
            ctx.accounts[_from] -= _value
            ctx.accounts[_to] += _value
            ctx.Transfer(_from, _to, _value)
            return OK
        else:

            return INSUFFICIENTFUNDS