Why is constructor not being recognized when being referenced? - ethereum

I'm trying to code a token and it is not recognizing constructor.. why?

You're trying to deploy the ERC20 (parent) contract, not the Avenger.
Select the Avenger contract in the "Deploy & Run transactions" tab, under the "Contract" label (just above the orange "Deploy" button). Then it will ask you to pass the constructor param(s).

Related

SOLIDITY: Create multiple contracts from one parent contract and listen for events from child contract

What is the best architecture to allow users to deploy their own smart contracts (NFT collections), and still be able to index the tokens created on those dynamically created contracts using something like The Graph subgraphs?
Currently the idea was to have a "Factory" contract deployed by me, so easily indexable, and inside that have a function createCollection that will deploy a contract using the new <ContractName> keyword.
Is this bad architecture? Would this even work?
The end goal is to allow users to deploy contracts from a UI, but still be able to listen for their events through my parent contract, so that I can index everything in a subgraph.
What you can actually do is to save a pointer to the parent contract into each generated contract. Thus, whenever you have an event you want to store into the parent contract, you can maybe interact with a function in it. But you may also want some type of verification to ensure that only child contracts can call the parent functions and not external contracts, so maybe you could make a mapping indexing the address of the generated child contracts, which will be able to call functions from the parent. What you can not do is to make the parent automatically look for events on the child's contracts.
Hope you find this information helpful :)

Saving external event variable into smart contract storage variable

I am trying to save a variable that gets emmited by an event, from a function in another smart contract, that I’m calling, into a storage variable within my smart contract.
So my call looks something like this:
ExternalContract.foo(boo);
The event in ExternalContract that contains the desired variable:
emit Event(bytes desiredVariable)
So I want to save this variable in my contract without relying on an off-chain script. Is there even a way to do it?
The Log and its event data is not accessible from within contracts (not even from the contract that created them).
Source: https://docs.soliditylang.org/en/v0.8.7/contracts.html#events
So unless there's a getter function for the desiredVariable, or unless it's stored in a public property (they have automatically generated getter functions as well), there's no way to get the event log value from a contract, and you'll need to use an off-chain app.

Solidity - What version of the contract do I deploy?

I am currently learning Solidity and I have made my first BSC test contract with no errors. I have compiled my contract successfully and I am now in the deployment section of Remix.
There is a drop down menu named "contract" and within there, there are the following options:
test.sol...ApproveAndCallFallback
test.sol...BEP20Interface
test.sol...Owned
test.sol...SafeMath
test.sol...TokenBEP20
test.sol...
I am a bit confused as to which I actually deploy for my contract as there are multiple options. Could someone please point me in the right direction for descriptions of these options?
Thanks!
In the contract selectbox, you select the main contract that you want to deploy.
Most likely you have written the TokenBEP20 token and it's going to be the TokenBEP20, but it all depends on your context.

How to call contract function from already deployed contract in Ethereum

I have an anready deployed contract in Enthereum.
And I want to call function from it.
Now I can do that:
watch_addr.call(bytes4(sha3("register()")))
But only when function has no parameters.
With parameters I try this, but have no success:
watch_addr.call(bytes4(sha3("register("This text is hard codded")")))
I read this solution: https://ethereum.stackexchange.com/questions/2826/call-function-on-another-contract
But I can't do that, because first contract is already deployed and when I deploy second contract, I don't know source code of first.
So, that solution is not for me.
I need a command like this:
watch_addr.call(bytes4(sha3("register("This text is hard codded")")))
How I can call function with parameters from other contract?
Any ideas...
watch_addr.call(bytes4(sha3("Bar(int256)")), 42);

MVVM - Share encapsulated model with other VMs

In my Windows Phone App there's a simple hierarchical model consisting of a class containing a collection of other domain objects.
In my xaml i have declared an ItemsContainer control that renders the items in the above mentioned collection as simple rectangles.
Now, at the VM level i have a structure that resembles my model with a parent VM having a collection of children VMs. Each child-VM encapsulates its own model.
Whenever the user taps the view bound to a child-VM a method of the parent-model object should be invoked taking the relevant child-model as parameter. This will in turn change some internal state that will be reflected (possibly) on all the child-views (not just the tapped one).
SO... given that i'm using the MVVM Light framework my current implementation is as follows:
Child-VM exposes a command
The command Execute method will use the messenger to notify the parent-VM of the tap event. The message (GenericMessage class) content will be the domain object encapsulated by the VM
The parent-VM executes the method of the parent-model using the message content as parameter
If the operation succeeds the parent-VM sends a new message to inform child-VMs of this fact. Once again the message content is the model object used as parameter in the method that was just invoked
Child-VMs raise a couple of PropertyChanged events that, finally, will update the bound views
It works but i fill it's a bit cumbersome. The thing that bugs me the most is the fact that when a child-view is tapped the associated VM will broadcast its encapsulated model object. Do you feel that there would be a better way of implementing such a system?
Thanks in advance for your precious help
Could you not just put the command on the parent viewmodel and pass the child viewmodel as the command parameter?
The parent view model can then just call methods on the child viewmodels to update them. I'm not sure I see the need for all these messages?