tma-staking-contracts
v0.0.2
Published
## システム構成
Downloads
3
Readme
TMAsステーキングシステム
システム構成
コントラクトアドレス
Mainnet
未デプロイ
Goerli
未デプロイ
ステーキング対象コレクションへの組み込み方
パッケージインストール
npm i tma-staking-contracts --save-dev
StakingCollectionをコレクションのコントラクトに組み込み、下記メソッドにmodifilerwhenNotStaking(tokenId)
を追加する。
import "tma-staking-contracts/contracts/Locker/StakingCollection.sol";
contract Collection is ERC721, StakingCollection, AccessControl {
function approve(address to, uint256 tokenId) public virtual override whenNotStaking(tokenId) {
super.approve(to, tokenId);
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override whenNotStaking(tokenId) {
super.transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override whenNotStaking(tokenId) {
super.safeTransferFrom(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override whenNotStaking(tokenId) {
super.safeTransferFrom(from, to, tokenId, data);
}
}
setLocker(address value)
を実装する。
function setLocker(address value) external override onlyRole(ADMIN){
_setLocker(value);
}
フロント向けのインターフェース
ITMAsLocker
function isLocked(address collectionAddress, uint256 tokenId)
external
view
returns (bool);
TMAおよびTMAsのコントラクトアドレス、トークンIDを引数にロック中かどうかを返す。
ロック中ならtrue
。
IAMTManager
function amt(address user) external view returns (uint256);
引数のアドレスが保有するAMTを返却する。
function add(address to, uint256 value) external;
to
のアドレスに対して、value
の値分だけAMTを付与する。
AMT_ADD_OPERATOR
ロールを持つmsg.sender
のみ利用可能。
event AddedAMT(address indexed user, uint256 amount);
を発行する。
function use(address from, uint256 value, string calldata action) external;
from
のアドレスから、value
の値分だけAMTを削減する。
AMT_USE_OPERATOR
ロールを持つmsg.sender
のみ利用可能。
event UsedAMT(address indexed user, string indexed action, uint256 amount);
を発行する。