The specific arrangement can work, you can basically say your getting royalities for your contribution. Same as inventors get royalties for companies using their patented designs to build products.
Typically I have seen values of 5% to 8% per product sold.
DO NOT do on profits. Because profits can be manipulated by accountants, do it on units sold. They sold 1 item for $100, you get paid your $10 end of story.
When should OR shouldn't you do this?
If you are just doing one specific component and are not going to be building and supporting the system long term. Then its a good model because you have a passive income and no risk.
If you are building large slabs of the system and then, ongoing becoming a developer for the new company, then you want to work out a base line set of wages ... You should be going for shares in the company at this point.
IF you want to build a business and invest your time and skill long term then you should be targeting the company.
What to consider
- You want to have the agreement in writing that you are getting royalities per product sale.
- You want this while any of your code still exists in the product.
- This includes sale to a 3rd party entity.
- What happens if they build a new version quickly and discontinue your work? This is where you would have wanted shares in the company.
Royalties are great because you get your money early as possible and without having to worry about all the business risks and issues.
Company shares are great because you get a say in what goes on and you build more than just the product, you have say in your own future and you can build many products over time for the business.
It comes down to what you want to do in the next few years.