谁能向我解释映射或挂钩发生的位置?以价格与黄金挂钩的 PAXG 为例。我如何使用我的 erc-20 令牌做到这一点?是写在代码里还是跟交易所有关系?
答案 0 :(得分:0)
其中大部分与代币代码无关,是一个经济学主题。这是 StackOverflow 上的题外话,所以我只想简单地说一些只是部分正确的:只要有足够多的买家和卖家愿意以黄金的价格购买/出售代币,代币就会有黄金价格。
但是,您可以在合同中定义控制其总供应量的函数,这会影响价格(有时会影响价格 - 再次影响经济)。
看看 PAXG source code:
/**
* @dev Increases the total supply by minting the specified number of tokens to the supply controller account.
* @param _value The number of tokens to add.
* @return A boolean that indicates if the operation was successful.
*/
function increaseSupply(uint256 _value) public onlySupplyController returns (bool success) {
totalSupply_ = totalSupply_.add(_value);
balances[supplyController] = balances[supplyController].add(_value);
emit SupplyIncreased(supplyController, _value);
emit Transfer(address(0), supplyController, _value);
return true;
}
/**
* @dev Decreases the total supply by burning the specified number of tokens from the supply controller account.
* @param _value The number of tokens to remove.
* @return A boolean that indicates if the operation was successful.
*/
function decreaseSupply(uint256 _value) public onlySupplyController returns (bool success) {
require(_value <= balances[supplyController], "not enough supply");
balances[supplyController] = balances[supplyController].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit SupplyDecreased(supplyController, _value);
emit Transfer(supplyController, address(0), _value);
return true;
}
通过执行这些函数(只能从授权地址执行 - 此检查在 onlySupplyController
修饰符中执行),您可以操作 {{1} 的值中存在的地址余额} 属性。
其他将其价值与某些链下资产挂钩的代币也具有内置的 supplyController
函数(有时还有 buy
函数),允许从/以预定义的价格提供给预定义的持有者。这也可能会激励买家和卖家使用内置功能,而不是在交易所使用利润较低的价格,这可能会有效地影响价格。