README
ethereum-api-deposit
Contracts for funding the API backend with VidyCoins and/or ether
Install
$ yarn add @vidy-dev/ethereum-api-deposit
or
$ npm install @vidy-dev/ethereum-api-deposit
Deposit Accounts
Deposit accounts are single-signature wallets which hold ether
or ERC20
tokens on behalf of the backend API, and keep a record of each outgoing transfer (both in Solidity event logs, and in internal transfer lists).
Each outgoing transfer is associated with a unique nonce (uint256
), set by the wallet owner. The nonce appears in both record formats for easier queries.
Public Interface
Events
event Transferred(address indexed token, address indexed to, uint256 amount, uint256 indexed nonce)
: Emitted when ether or ERC20 tokens are transferred from the deposit account. token
indicates the address of the ERC20 contract, 0x0
if ether was transferred.
event TransferredEther(address indexed to, uint256 amount, uint256 indexed nonce)
: Emitted when ether is transferred from the deposit account. A Transferred
event will also be emitted.
event TransferredTokens(address indexed token, address indexed to, uint256 amount, uint256 indexed nonce)
: Emitted when ERC20 tokens are transferred from the deposit account. token
indicates the address of the ERC20 contract. A Transferred
event will also be emitted.
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
: Emitted when the deposit account (and any ether / ERC20 tokens it contains) is transferred to a new owner.
Fields and Constant Functions
mapping(uint256 => bool) public nonceUsed
: Whether a particular nonce value has already been used to represent a transfer. Nonces cannot be repeated.
mapping(uint256 => Transfer) public transfers
: The Transfer struct associated with a particular nonce.
uint256 public transferCount
: The number of transfers that have been performed so far.
mapping(address => uint256) public totalTransferred
: For each token address (0x0
for ether), the total amount that has been transferred out of the account.
tokenBalance(function tokenBalance(address _token) public view returns (uint256)
: An alias for balanceOf()
called on the token contract -- returns the amount of tokens owned by the deposit account.
Non-constant Functions
function transferEtherToOwner(uint256 _value, uint256 _nonce) public onlyOwner returns (bool)
: Transfers the indicated amount of ether (measured in wei) to the current contract owner, returning success. Only the contract owner can perform this operation.
function transferEther(address _to, uint256 _value, uint256 _nonce) public onlyOwner returns (bool)
: Transfers the indicated amount of ether (measured in wei) to the indicated address, returning success. Only the contract owner can perform this operation.
function transferTokensToOwner(address _token, uint256 _value, uint256 _nonce) public onlyOwner returns (bool)
: Transfers the indicated amount of the ERC20 token at the specified address to the current contract owner, returning success. Only the contract owner can perform this operation.
function transferTokens(address _token, address _to, uint256 _value, uint256 _nonce) public onlyOwner returns (bool)
: Transfers the indicated amount of the ERC20 token at the specified address to the indicated recipient, returning success. Only the contract owner can perform this operation.