No funded issue found.
Check out the Issue Explorer
Be the OSS Funding you wish to see in the world.
Looking to fund some work? You can submit a new Funded Issue here .
Time left
Opened
Issue Type
Workers Auto Approve
Project Type
Time Commitment
Experience Level
Permissions
Accepted
Reserved For
Get contract address from registry instead of from operator
plasma-group
JavaScript
This is a great first issue because it'll introduce you to some of the key components that make up `plasma-core`.
---
`plasma-core` always connects to a specific plasma chain smart contract. However, before it can connect to the contract, it needs to figure out the address of that contract. Currently we're kinda cheating and grabbing the contract address from the operator:
https://github.com/plasma-group/plasma-core/blob/4329f1292273a84604ccba32573f0d574a189006/src/services/contract/http-provider.js#L52-L61
This is bad because it means the operator can trick the client into depositing money into the wrong contract. You could, in theory, check that the code at that address matches the code of the smart contract, but it's easier to use the [Plasma Chain Registry](https://github.com/plasma-group/plasma-contracts/blob/master/contracts/PlasmaRegistry.vy).
The Registry is a smart contract with some public mappings:
```
plasmaChainNames: public(map(bytes32, address))
plasmaChainIPs: public(map(address, bytes32))
```
This means the operator can just give you a plasma chain name and you can resolve both the plasma chain smart contract *and* the operator's IP. For now, let's just worry about the address.
Note that this also means we need `plasma-core` to know the plasma registry address! Unfortunately there's no great trustless way to do this. We should probably just have this as an option with a default that points to some known and stable registry.
Once we have the registry address, we're going to need to create a new contract instance. Luckily, `plasma-contracts` exposes the ABI of `PlasmaRegistry`, so this isn't too complicated:
```
const plasmaChainName = options.plasmaChainName
const registryAddr = options.registryAddress
const registryCompiled = require('plasma-contracts').plasmaRegistryCompiled
const registryContract = new web3.eth.Contract(registryCompiled.abi, registryAddress)
const contractAddress = await registryContract.methods.plasmaChainNames(plasmaChainName).call()
```
This logic should occur in [ContractProvider](https://github.com/plasma-group/plasma-core/blob/master/src/services/contract/http-provider.js).
## TODO
- [ ] Query contract address from registry.
- [ ] Remove old method of querying from operator.
Setup your profile
Tell us a little about you:
Skills
No results found for [[search]] .
Type to search skills..
Bio Required
[[totalcharacter]] / 240
Are you currently looking for work?
[[ option.string ]]
Next
Setup your profile
Our tools are based on the principles of earn (💰), learn (📖), and meet (💬).
Select the ones you are interested in. You can change it later in your settings.
I'm also an organization manager looking for a great community.
Back
Next
Save
Enable your organization profile
Gitcoin products can help grow community around your brand. Create your tribe, events, and incentivize your community with bounties. Announce new and upcoming events using townsquare. Find top-quality hackers and fund them to work with you on a grant.
These are the organizations you own. If you don't see your organization here please be sure that information is public on your GitHub profile. Gitcoin will sync this information for you.
Select the products you are interested in:
Out of the box you will receive Tribes Lite for your organization. Please provide us with a contact email:
Email
Back
Save