-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Connect infuraWebsocket and subsribe perticular event in swift? #193
Comments
pls give me example how to connect infura websocket and how to subscribe own event and get data from url in swift4 ? very crititcal and confusing |
Hi, @Ashish8460 . You can start at https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#websockets. class DelegateClass: Web3SocketDelegate {
var socketProvider: InfuraWebsocketProvider? = nil // Infura WebSocket Provider
// Protocol method, here will be messages, received from WebSocket server
func received(message: Any) {
// Make something with message
}
func some() {
// Connecting to mainnet Infura wss endpoint
socketProvider = InfuraWebsocketProvider.connectToInfuraSocket(.Mainnet, delegate: self)
// Subscribing your events
try! socketProvider.subscribeOnLogs(addresses: [Addresses of your contracts], topics: [Topics of your logs])
}
} |
try! socketProvider.subscribeOnLogs(addresses: [Addresses of your contracts], topics: [Topics of your logs]) // I can't get this method in infuraWebSocketProvider. |
On May 13, 2019, at 6:38 AM, Anton Grigorev ***@***.***> wrote:
Hi, @Ashish8460 <https://github.com/Ashish8460> . You can start at https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#websockets <https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#websockets>.
And for complete understanding https://infura.io/docs/ethereum/wss/introduction <https://infura.io/docs/ethereum/wss/introduction>.
Think you need something like that:
class DelegateClass: Web3SocketDelegate {
var socketProvider: InfuraWebsocketProvider? = nil // Infura WebSocket Provider
// Protocol method, here will be messages, received from WebSocket server
func received(message: Any) {
// Make something with message
}
func some() {
// Connecting to mainnet Infura wss endpoint
socketProvider = InfuraWebsocketProvider.connectToInfuraSocket(.Mainnet, delegate: self)
// Subscribing your events
try! socketProvider.subscribeOnLogs(addresses: [Addresses of your contracts], topics: [Topics of your logs])
}
}
- I don’t get socketProvider.subscribeOnLogs(addresses: [Addresses of your contracts], topics: [Topics of your logs]). In my project
- can you give me example of it how to pass parameters and subscribe event urgent!
|
@Ashish8460 hi, sorry, was on my vacation without stable wifi. Is the problem relevant? I use subscribeOnLogs as I've written in the example above without any troubles. try! self.socketProvider!.subscribeOnLogs(addresses: [EthereumAddress("0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359")!], topics: ["ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]) |
I know this is an old thread but someone might find it useful, I was having troubles trying to connect through subscribe to logs using websockets and even the example given here was not working for me, maybe there was a change on how infura processes the request but it seems that now topics must be prefixed by '0x' in order for subscriptions to work. |
|
No description provided.
The text was updated successfully, but these errors were encountered: