Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

I can not use my contract ? #43

Closed
wufeiafei opened this issue Apr 8, 2018 · 17 comments · Fixed by #48
Closed

I can not use my contract ? #43

wufeiafei opened this issue Apr 8, 2018 · 17 comments · Fixed by #48
Labels

Comments

@wufeiafei
Copy link

wufeiafei commented Apr 8, 2018

hi,
my contract is here:
image

but, when I use web3wift, the contract is not work.
this is my code:
1523182536695
1523196595604

I use the method"setFlagData" and "getFlagData", but no work.

the result like this:
the "setFlagData" result:
res:
.success([:])
and the "getFlagData" result:
get res:
.success(["0": ""])

what can I do?

@shamatar
Copy link
Contributor

shamatar commented Apr 8, 2018

Hello @wufeiafei

Are you sure that "getFlagData" method doesn't return an empty string for this msg.sender? If it does, than your result is correct, you get a default (empty) value.

Regarding the "setFlagData" result: .success([:]) is a valid response if you "call" this method, since it returns nothing in your contract code. To send a transaction and mutate a state your should use a send() method of transaction intermediate

Sincerely, Alex

@shamatar shamatar added the bug label Apr 8, 2018
@wufeiafei
Copy link
Author

the "getFlagData" method return: .success(["0": ""])
I think the result should be "hello", when I used "setFlagData" method input.
but not get.

@shamatar
Copy link
Contributor

shamatar commented Apr 8, 2018 via email

@wufeiafei
Copy link
Author

hi, when I use the latest version (0.4.1),
the "setFlagData" method log message is:
1523238415923

and the "getFlagData" method log message is :
1523238448698

what is mistake?

@shamatar
Copy link
Contributor

shamatar commented Apr 9, 2018

Hello @wufeiafei

I've created a similar contract

pragma solidity ^0.4.21;


contract Whisper {
    
    struct Friend {
        string flagData;
    }
    
    mapping (address => Friend) friends;
    
    function setFlagData(string data) public {
        friends[0].flagData = data;
    }
    
    function getFlagData() public view returns (string data) {
        return friends[0].flagData;
    }
    
}

and submitted some data to it using remix. Here is my response:

["0": testData, "data": testData]

You can find a code in test cases in developer branch, function

func testUserCase()

@wufeiafei
Copy link
Author

yes, I test your code and get the"getFlagData" response like that: ["0": testData, "data": testData],when I submitted some data to it using remix.
But ,if I use "setFlagData" method by web3swift in iOS , the "setFlagData" method response is :
string
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000046874747000000000000000000000000000000000000000000000000000000000
Full data:

.success([:])

then, I use "getFlagData", the response is the old, not the new.

this is my code:
1523271638574

@shamatar
Copy link
Contributor

shamatar commented Apr 9, 2018 via email

@wufeiafei
Copy link
Author

hi, I instead use send() method on intermediate,
1523274591548

but the result is fail.

string
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000968656c6c6f576562330000000000000000000000000000000000000000000000
Transaction
Nonce: 1
Gas price: 5000000000
Gas limit: 90000
To: 0xb6b34A03045D8Aa0D210788881bffEc10c4f166e
Value: 0
Data: 0xa46b5b6b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000968656c6c6f576562330000000000000000000000000000000000000000000000
v: 1
r: 0
s: 0
Intrinsic chainID: Optional(95518)
Infered chainID: Optional(1)
sender: nil
hash: Optional("0xe1719833c6cc8ccca0af6e24a0be8cbdc93aeefbd17237d56bfc217705e5e777")

set result
.failure(transactionSerializationError)
transactionSerializationError

@shamatar
Copy link
Contributor

shamatar commented Apr 9, 2018

I've found a bug in sending an unsigned transaction to external node. Fixed in #44

@wufeiafei
Copy link
Author

wufeiafei commented Apr 10, 2018

hi, when I use the lastest code by pod 'web3swift', git: 'https://github.com/BANKEX/web3swift.git',:commit =>'782d5ee' ,
show the erros like this:
1523328664984

what can I do?

@wufeiafei
Copy link
Author

wufeiafei commented Apr 11, 2018

hi,
I use the lastest code version 0.5.0.
but the use "setFlagData" method in contract, the result also is bad.
1523425045711

the log and result is :

sender:
EthereumAddress(_address: "0x696e2405d2c914228e4409307372aacb470ad833")
Signature required 3 rounds
Transaction
Nonce: 0
Gas price: 5000000000
Gas limit: 90000
To: 0xb6b34A03045D8Aa0D210788881bffEc10c4f166e
Value: 0
Data: 0xa46b5b6b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000968656c6c6f576562330000000000000000000000000000000000000000000000
v: 191071
r: 115484963803047457941187315055774630604535195829756633299156415369938984242572
s: 5606618538296490632424069479196750027399791712033427709004373420558424659314
Intrinsic chainID: Optional(95518)
Infered chainID: Optional(95518)
sender: Optional("0x696e2405d2C914228E4409307372aACb470aD833")
hash: Optional("0xe8677fee1e5c800b478330c2de6980daf28776a519e5eff1c941c66f94e5d67c")

Transaction
Nonce: 0
Gas price: 5000000000
Gas limit: 90000
To: 0xb6b34A03045D8Aa0D210788881bffEc10c4f166e
Value: 0
Data: 0xa46b5b6b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000968656c6c6f576562330000000000000000000000000000000000000000000000
v: 191071
r: 115484963803047457941187315055774630604535195829756633299156415369938984242572
s: 5606618538296490632424069479196750027399791712033427709004373420558424659314
Intrinsic chainID: Optional(95518)
Infered chainID: Optional(95518)
sender: Optional("0x696e2405d2C914228E4409307372aACb470aD833")
hash: Optional("0xe8677fee1e5c800b478330c2de6980daf28776a519e5eff1c941c66f94e5d67c")

set result
.failure(nodeError("invalid sender"))
nodeError("invalid sender")

=========
can you help me check it?

@shamatar
Copy link
Contributor

shamatar commented Apr 11, 2018 via email

@wufeiafei
Copy link
Author

hi,
I added "web3.provider.network = nil " to code,but has errior:Cannot assign to property: '' is a get-only property。
1523436248529

I see the code in Web3+Protocols.swift:
1523436291751
so can not set web3.provider.network = nil

@shamatar
Copy link
Contributor

shamatar commented Apr 11, 2018

Hello @wufeiafei

Can you test agains the latest master? After #48 you can set a network to nil

@skywinder
Copy link
Contributor

@wufeiafei Fixed by #48
Feel free to reopen the issue, if you still need help. 👍

@zeroXBami
Copy link

i have a question: I already have SmartContract in Solidity, how can i get contract ABI in json?

@shamatar
Copy link
Contributor

shamatar commented May 4, 2018

If you use Remix, it’s in details on the first tab, near the “compile” button

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants