Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Is there any real world example of nested mappings of solidity?

Is there any real world example of nested mappings of solidity? The previous day I was working with mapping functions and I found literally many real world applications for simple mapping but not for nested mappings. Please help enter image description here

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

A very common case is the approval mechanism on ERC-20 and other token standards.

mapping (address => mapping (address => uint256)) approvals;

This structure is used to keep track of token approvals. Example: "Alice (1st address) approves Bob (2nd address) to spend 100 (uint) of her tokens".

A more common case than "approvals between people" is usually an approval from a person to a DApp. For example: "Alice approves Uniswap to pull 100 USDT from her wallet." And Uniswap is programed to take her USDT only at the moment when she's buying some other tokens against USDT.

It's also used for the same reason in the OpenZeppelin ERC20 implementation.

about 4 years ago · Juan Pablo Isaza Report

0

Yes, today I had an example of that: In a NFT contract I wanted to create a mapping of metadata linked to addresses. So I tried it:

//create a mapping
mapping(string => address) public metadataUri;

//set a mapping
metadataUri[_uri] = _address;

But in that case, if I have one more address with the same string, the first one will override all next addresses with the same string. So in that case I should have something like this:

//create a mapping
mapping(string => mapping(address => uint)) public metadataUri;

//set a mapping
metadataUri[_stringURI][_address] = _uint;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!