Skip to content

Please explain the idea of an array of contracts and the implementation of "sfStore" function #3412

Answered by pacelliv
kprabhasreddy asked this question in Q&A
Discussion options

You must be logged in to vote

In this contract you wan to create as many SimpleStorage contracts you want, every time a new SimpleStorage is created it will be store in simpleStorageArray to be access whenever you want via its index.

The new contracts are added to simpleStorageArray using the push() method. This method allows you to add new elements to an array.

What happens if you have 5 SimpleStorage and you want to add numbers to them? sfStore takes two parameters: the index of a contract and the number to store, with these parameters you could add a number to any contract that is already stored in simpleStorageArray. This also apply to sfGet, if you pass an index to this function it will show you what number is s…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@kprabhasreddy
Comment options

Comment options

You must be logged in to vote
1 reply
@alymurtazamemon
Comment options

Answer selected by alymurtazamemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants