Skip to content

Commit

Permalink
refactor: 💡 update ERC5169 doc
Browse files Browse the repository at this point in the history
  • Loading branch information
futantan committed Dec 1, 2023
1 parent 38557f5 commit 942ec02
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions pages/store/implement5169.mdx
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
# How to implement ERC5169
# How to implement ERC-5169

1. Install [stl-contracts](https://www.npmjs.com/package/stl-contracts) NPM module with command ```npm i stl-contracts```
Implementing ERC-5169 can be conveniently achieved by inserting several lines of code.

2. Add next code to your contract
1. Install [stl-contracts](https://www.npmjs.com/package/stl-contracts) package:

```sh npm2yarn copy
npm i stl-contracts
```

2. Add following code to your contract

```solidity copy
import "stl-contracts/ERC/ERC5169.sol";
contract ERC721Mint is Ownable, ERC5169, AccessControl, ERC721Enumerable {
function supportsInterface(bytes4 interfaceId)
public view override(ERC5169, ERC721Enumerable)
returns (bool)
{
return
ERC721Enumerable.supportsInterface(interfaceId) ||
ERC5169.supportsInterface(interfaceId);
function supportsInterface(bytes4 interfaceId) public view override(ERC5169, ERC721Enumerable) returns (bool) {
return ERC721Enumerable.supportsInterface(interfaceId) || ERC5169.supportsInterface(interfaceId);
}
// limit set contracts to admin only
function _authorizeSetScripts(string[] memory) internal view override(ERC5169) onlyOwner {}
}
```

3. In case if you don't implement **Ownable** interface then replace **onlyOwner** with your modifier to limit use of **_authorizeSetScripts** to admin or other user/group
3. In case if you don't implement **`Ownable`** interface then replace **`onlyOwner`** with your modifier to limit use of **`_authorizeSetScripts`** to admin or other user/group

4. When contract deployed run command to add script to your contract
4. When contract deployed run the following script to set the `scriptURI`

```
let scripts = ["https://your.hosting.com/messaging_mumbai.tsml"]
```js {8} copy
const [owner] = await ethers.getSigners();
const ERC721Mint = await ethers.getContractFactory("ERC721Mint");

const ERC721Mint = await ethers.getContractFactory('ERC721Mint');
const nft = await ERC721Mint.attach(contractAddress);
let tx = await nft.connect(owner).setScriptURI(scripts)

let tx = await nft
.connect(owner)
.setScriptURI(['https://your.hosting.com/messaging_mumbai.tsml']);
await tx.wait();
```

When script added then NFTs (which user own) for this contract will appear under [Smart Token Store](https://smart-token-store.vercel.app/)
When script added then NFTs (which user own) for this contract will appear under [Smart Token Store](https://store.smartlayer.network/)

0 comments on commit 942ec02

Please sign in to comment.