These are chat archives for ethereum/solidity

18th
Mar 2018
Jack Tang
@jacktang
Mar 18 2018 01:48 UTC
Hello, any know the below error
TypeError: Unable to deduce common type for array elements.
        RaisedMilestoneRate rmRateStrategy = new RaisedMilestoneRate([[10 * (10**18), 10/(10**18)]]);
                                                                      ^--------------------------^
what is the meaning of Unable to deduce common type for array elements?
gpanula
@gpanula
Mar 18 2018 02:15 UTC
just guessing... but it looks like the first element is an integer and second element is a float. compiler is having trouble determining an element type that will encompass both elements.
guessing you'll need to explicitly set the type
or make sure both elements are the same type (e.g. integer)
Jack Tang
@jacktang
Mar 18 2018 02:19 UTC
@gpanula you're, now I cast both to uint256 explicitly, and passed compiling now. Thanks!
gpanula
@gpanula
Mar 18 2018 02:20 UTC
huzzah. glad I could help
laitassou
@laitassou
Mar 18 2018 11:59 UTC
Hi
I developed a dapp like cryptokitties, any advice for status, do you i need create companie etc
Nick Allen
@nicallennn
Mar 18 2018 12:09 UTC
hi

hi all, new here. was looking for some help solving an issue i have.

I have a sol contract that has a mapping that stores a custom struct type (jobs). in the function below i am sorting through all existing jobs to fins the ones that have not currently been paid. i pass in a bool to determine whether to filter the unpaid jobs by the jobs admin variable or client variable. if i pass true, which represents an admin user it filters fine and returns an array with only the jobs where jobs[i].admin == msg.sender. However if I pass in false, to filter by jobs[i].client == msg.sender I just get an empty array back. I have removed code here an there to determine that it is infact to do with the line "jobs[i].paid == false && jobs[i].client == msg.sender". if i remove jobs[i].client == msg.sender then i get all results but with it i get empty array.

If anyone knows a reason this is happening i would be eternally grateful if you could share this knowledge with me.

ps. i get no errors and everything runs ok.

'''
function getUnpaidJobs(bool adminOrClient) public view returns (uint[]) {
//output array
uint[] memory jobIds = new uint;

    //unpaid job counter
    uint unpaid = 0;

    //iterate jobs
    for(uint i = 1; i <= jobCounter; i++) {
        //if unpaid add to array

        //if admin user, get unpaid jobs
        if(adminOrClient){
            if(jobs[i].paid == false && jobs[i].admin == msg.sender) {
              jobIds[unpaid] = jobs[i].jobId;
              unpaid++;
            }
        }

        //if client user, get unpaid jobs, && jobs[i].client == msg.sender
        else{
            if(jobs[i].paid == false && jobs[i].client == msg.sender) {
              jobIds[unpaid] = jobs[i].jobId;
              unpaid++;
            }
         }
      }

    //initialise new memory array with size of unpaid variable
    uint[] memory sortedJobs = new uint[](unpaid);

    //copy jobIds array to new smaller array
    for(uint j = 0; j < unpaid; j++) {
        sortedJobs[j] = jobIds[j];
    }

    //return sorted array
    return sortedJobs;

}

'''

Daniel
@DanielRX
Mar 18 2018 12:11 UTC
Well are you the client for any jobs as the admin?
Nick Allen
@nicallennn
Mar 18 2018 12:14 UTC
yes so when testing this with truffle i call the function with the {from: } parameter set to the two different accounts i am using to add jobs. when passing true, and using {from:} i get the different jobs
for each user
but when passing false, and using {from:} with the different accounts i get nothing back
Daniel
@DanielRX
Mar 18 2018 12:15 UTC
Well first off, you shouldn't check jobs[i].paid == false...
You just say !jobs[i].paid
What is the struct def of job?
Nick Allen
@nicallennn
Mar 18 2018 12:16 UTC

'
//job structure
struct Job {
uint jobId;
address admin;
address client;
string name;
string description;
uint256 quoteNo;
uint256 price;
bool paid;

    //date tracking variables
    string dateMade;
    string datePaid;
}

'

not sure why that formatted weird, but this is it
Daniel
@DanielRX
Mar 18 2018 12:17 UTC
you used only 1 `
and also used ' not `
Are you looking for jobs the user is the client for or the admin for?
As you getting the right results with true implies admin
Nick Allen
@nicallennn
Mar 18 2018 12:19 UTC
yeh so if true, it gets the jobs where user == admin, which works fine.
if false, it gets jobs where the user == client, which returns empty.
Daniel
@DanielRX
Mar 18 2018 12:19 UTC
yes, I know, so are you sure you have set client to be correct on the job?
Nick Allen
@nicallennn
Mar 18 2018 12:20 UTC
i mean, the only difference is jobs[i].admin has been changed to jobs[i].client
yes i have checked the client field of the jobs
Daniel
@DanielRX
Mar 18 2018 12:20 UTC
yes. but they have different values (unless you set them to be the same)
Nick Allen
@nicallennn
Mar 18 2018 12:22 UTC
yeh , exactly. no they are not set to the same value.
Daniel
@DanielRX
Mar 18 2018 12:23 UTC
Okay, can you post a MWE on gist with some snippets of jobs so I can throw it in remix?
and my question is this, is there a job in the list that has a client for each {from:}
Nick Allen
@nicallennn
Mar 18 2018 12:25 UTC
yes there is.
lemme just go over this and check again. but 99% sure.
Nick Allen
@nicallennn
Mar 18 2018 12:39 UTC
this opens a new debate whether or not the client address is being stored correctly. i am going to go over this now so will try to resolve myself. thankyou for your help though. it is very much appreciated.
Nick Allen
@nicallennn
Mar 18 2018 12:49 UTC
ok. this is interesting. I am passing the client address as: 0xf17f52151EbEF6C7334FAD080c5704D77216b732, however it is being stored as:
0xf17f52151ebef67f5f4ec4f6a29a735000000000
Pavlos Polianidis
@ppoliani
Mar 18 2018 12:50 UTC
@nicallennn are you passing from web3?
if so use quotes
Nick Allen
@nicallennn
Mar 18 2018 12:50 UTC
no i just just hardcoded it. i will try this. thanks
SOLVED
i was not passing the address in single quotes in the function arguments
double quotes doesnt seem to work
awesome. thank you guys.
Pavlos Polianidis
@ppoliani
Mar 18 2018 12:53 UTC
:thumbsup:
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:38 UTC
Anyone here can view this contract code, and answer a simple question about it
Daniel
@DanielRX
Mar 18 2018 17:39 UTC
@Aminadav go on?
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:41 UTC
I'm trying to understand the code, and it seems that there is lot of unused code, that never can be executed.
The name of the deployed contract is "LeadcoinSmartToken".
The source code contain many contract inside, and some of them (For e.g. LeadcoinCrowdsale) it seems not been used by this code. So why is it exist?
Maybe is it possible to call those functions in those contracts from other place?
Daniel
@DanielRX
Mar 18 2018 17:43 UTC
All of the code is used
Is it deployed as crowdsale or token?
If it's just the token, then yes the crowdsale is not needed, but it looks like this would be used for both (for easier deployment, as much as it's a bad thing)
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:45 UTC
Why do you say that? EtherScan said that the ContractName is "LeadcoinSmartToken". The contract in line 670 never used
Daniel
@DanielRX
Mar 18 2018 17:45 UTC
^
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:46 UTC
I'm not understand, how is it possible to use the crowdsale, if it deployed as a token?
You can see that it's deployed as a token, so no one used the code of the crowdsale
Daniel
@DanielRX
Mar 18 2018 17:46 UTC
I'm saying they likely had one file, that they deployed as a token, then as a crowdsale
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:47 UTC
The code now, is looks like a token. (Now the deployed it as a token).
If they deployed it before as a crowdsale, they have lose all the token owners.
Daniel
@DanielRX
Mar 18 2018 17:48 UTC

1 file

Deployed twice, once for the crowdsale and one for the token

Instead of splitting the files as they should have
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:52 UTC

I'm understand you. I'm just saying that if it deployed twice. The second deploy will not have any information about the token holders, because each deploy have it's own state.

So it seems that they never did 2 deploies to the blockchain. And if so it will be absolutly two different tokens. (They can't share states)
Am I miss something?

Daniel
@DanielRX
Mar 18 2018 17:52 UTC

The first, will be the token.

The second will be a crowdsale, no tokens

if you have 2 contracts in one file, and you only use one, the other is still there
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:56 UTC
.
Daniel
@DanielRX
Mar 18 2018 17:56 UTC
If it is not included in the deployed main contract, does the compile optim it out?
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:56 UTC

So do you agree with me, that if Solidity compiler was smarter, he can see that those contracts never used (The deployed contract no inherit any of them), and it can skip compiling it?

It can save bytes & gas.

Daniel
@DanielRX
Mar 18 2018 17:56 UTC
Does it not already?
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:56 UTC
It seems that not. You see that the verified source contain it.
Daniel
@DanielRX
Mar 18 2018 17:57 UTC
Yes, so if the compiler removes it, the source will compile to the deployed contract
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:57 UTC
About what you said early. First deploy as a token, second as a crowdsale.
But the crowdsale is for selling tokens, but the crowdsale, do not have access to the deployed contract with the tokens.
So how is it possible to split it to two deploys?
Daniel
@DanielRX
Mar 18 2018 17:58 UTC
You just point the crowdsale to the token contract, in a variable
Aminadav Glickshtein
@Aminadav
Mar 18 2018 17:59 UTC
So if two contract are deployed. Where the wallet balances exists?
In the first contract , or the second contract?
Daniel
@DanielRX
Mar 18 2018 18:00 UTC
Whichever is the stores the tokens
Aminadav Glickshtein
@Aminadav
Mar 18 2018 18:01 UTC
So how the 2nd contract can change the state of the balance of the token?
If I will deploy a new contract, it can't transfer token balances. How the second contract can have permissions to do those changes?
Daniel
@DanielRX
Mar 18 2018 18:03 UTC
You add a modifier (onlyCrowdsale) that allows it to transfer
Notice how these have the same source, but different bytecode
Aminadav Glickshtein
@Aminadav
Mar 18 2018 18:05 UTC
Cool.
Daniel
@DanielRX
Mar 18 2018 18:05 UTC
So they method is not wasteful, but shows a big flaw in the verification
Aminadav Glickshtein
@Aminadav
Mar 18 2018 18:10 UTC
  1. Thanks for help me understand. So the source code verification do not contain all the contracts code.
  2. I'm not understand your answer "You add a modifier (onlyCrowdsale) that allows it to transfer)

They don't have this modifier.

The question is how is it possible to split the code of a token to 2 deployed contracts.
You said the first deployed contract may be as a token.
The second as a crowdsale.

Now the question: How the contract of the crowdsale have permissions and access to change balances that exist in the 1st contract?

The only idea I have maybe the first deployed contract sets the owner as the address of the second deployed contract. From the point, the second deployed contract, can make any balances changes using the owner permissions.
But it seems that even owner do not have access to change token balances.
Daniel
@DanielRX
Mar 18 2018 18:12 UTC
1) yes they do
2) this token may not, but another token might is what I am saying
this is only one version of an ERC20 token
Aminadav Glickshtein
@Aminadav
Mar 18 2018 18:18 UTC
Thanks!
Dillon Vincent
@dillonsvincent
Mar 18 2018 18:32 UTC

Hi everyone-

Please take a minute to help make smart contract development better for everyone. Im conducting a short survey of only 9 questions.

Thanks for your time,
https://goo.gl/forms/3O0fGVShtoamYLXM2
Dillon

Aminadav Glickshtein
@Aminadav
Mar 18 2018 18:33 UTC
@DanielMReed You right. I have found the "first" crowdsale contract:
https://etherscan.io/address/0x0c68fc2a91a81369956603bccbcdb95b87758b63#code
laitassou
@laitassou
Mar 18 2018 19:13 UTC
My first dapp is soon coming
My service is carpooling between users
phalexo
@phalexo
Mar 18 2018 19:17 UTC
I am curious how blockchain is useful for carpooling?
Daniel
@DanielRX
Mar 18 2018 19:18 UTC
It's not, AFAIK
It will just be the same as all these "blockchain version of X" projects
laitassou
@laitassou
Mar 18 2018 19:52 UTC
Carpooling is that you propose ride with your car and users who want to travel participate to fees
and blockchain is a system for reservation and paiment here
@phalexo hope this answers your question
beether
@beether
Mar 18 2018 20:38 UTC
Is it at all possible to verify, from an on-chain contract, that another contract implements some library?
mryellow
@mryellow
Mar 18 2018 21:25 UTC
jebuske
@jebuske
Mar 18 2018 21:31 UTC
If I have ContractA is contractB, Pausable and I want to be able to call a function from contractB even when ContractA is paused. How should I do this? its inheriting from ContractB so I cannot add a modifier in contractA?
cryptodon15
@cryptodon15_twitter
Mar 18 2018 21:42 UTC
Hey Guys any thoughts on this..... www.FluidAI.co
phalexo
@phalexo
Mar 18 2018 22:29 UTC
@jebuske You are confused about what Pausable does. Particular methods with modifier whenNotPaused are made to revert in case pause == true. There is no such thing as pausing a contract.
jebuske
@jebuske
Mar 18 2018 22:37 UTC
@phalexo Sorry, I maybe didnt explain myself correctly. So I have a contract ContractA is contractB, Pausable. When I change the pausedState of contractA to true I can no longer call the methods of contractB that it inherit because its in the paused state? I want to use the whenPaused modifier on these methods of contractB but I’m confused how this could be done
phalexo
@phalexo
Mar 18 2018 22:41 UTC
As long as methods inherited from contractB do not have that modifier on them you can call them. You can also have two(2) Pausable contracts, i.e. PausableA and PausableB controlling methods of A and B separately. Have to use different names for modifiers and flags.
jebuske
@jebuske
Mar 18 2018 22:51 UTC
@phalexo I’m afraid I dont understand how methods from ContractB can have a modifier from contractA on them? I guess thats what I’m trying to ask
I tried adding whenPaused in contractB but that doesnt work
Micky Socaci
@mickys
Mar 18 2018 22:55 UTC
@jebuske ContractA is ContractB, Pausable, -> if you deploy contractA at 0x01, and then deploy ContractB to 0x0X, A will have the full code of B, and code changes that A does, but they do not share state / storage, you inherit / extend b's code
they're not linked inside the blockchain in any way