OpenZeppelin / OpenZeppelin/openzeppelin-contracts

Add internal view method for _baseURI in ERC1155URIStorage.sol

Open
#4,209 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Solidity
Stars
27.2k
Forks
12.4k
Avg merge
2d 19h
Merged PRs (30d)
33

Description

🧐 Motivation
Hi, My contract inherit from ERC1155URIStorage.
In _baseURI I store the ipfs access url: "https://ipfs.io/ipfs/" and then in _tokenURIs, all CID of my token.
But on top of that, all tokens need to access to an other ipfs resource, and, because I can't access to _baseURI, I have to store "https://ipfs.io/ipfs/" a new time?

📝 Details
A solution could be to add this view function add the end of the contract.
/*
@dev Get _baseURI
*/
function _getBaseURI() internal view returns (string memory) {
return _baseURI;
}

It can be useful for other use case, is not risky because it's only a view method ...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading ERC1155URIStorage.sol and locate the _baseURI storage and access points. Check the contract's existing tests or usage for URI behavior, then confirm that the requested internal view access is available without changing how token URIs are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.